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 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 2756 2757 2758 2759 2760 2761 2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 2786 2787 2788 2789 2790 2791 2792 2793 2794 2795 2796 2797 2798 2799 2800 2801 2802 2803 2804 2805 2806 2807 2808 2809 2810 2811 2812 2813 2814 2815 2816 2817 2818 2819 2820 2821 2822 2823 2824 2825 2826 2827 2828 2829 2830 2831 2832 2833 2834 2835 2836 2837 2838 2839 2840 2841 2842 2843 2844 2845 2846 2847 2848 2849 2850 2851 2852 2853 2854 2855 2856 2857 2858 2859 2860 2861 2862 2863 2864 2865 2866 2867 2868 2869 2870 2871 2872 2873 2874 2875 2876 2877 2878 2879 2880 2881 2882 2883 2884 2885 2886 2887 2888 2889 2890 2891 2892 2893 2894 2895 2896 2897 2898 2899 2900 2901 2902 2903 2904 2905 2906 2907 2908 2909 2910 2911 2912 2913 2914 2915 2916 2917 2918 2919 2920 2921 2922 2923 2924 2925 2926 2927 2928 2929 2930 2931 2932 2933 2934 2935 2936 2937 2938 2939 2940 2941 2942 2943 2944 2945 2946 2947 2948 2949 2950 2951 2952 2953 2954 2955 2956 2957 2958 2959 2960 2961 2962 2963 2964 2965 2966 2967 2968 2969 2970 2971 2972 2973 2974 2975 2976 2977 2978 2979 2980 2981 2982 2983 2984 2985 2986 2987 2988 2989 2990 2991 2992 2993 2994 2995 2996 2997 2998 2999 3000 3001 3002 3003 3004 3005 3006 3007 3008 3009 3010 3011 3012 3013 3014 3015 3016 3017 3018 3019 3020 3021 3022 3023 3024 3025 3026 3027 3028 3029 3030 3031 3032 3033 3034 3035 3036 3037 3038 3039 3040 3041 3042 3043 3044 3045 3046 3047 3048 3049 3050 3051 3052 3053 3054 3055 3056 3057 3058 3059 3060 3061 3062 3063 3064 3065 3066 3067 3068 3069 3070 3071 3072 3073 3074 3075 3076 3077 3078 3079 3080 3081 3082 3083 3084 3085 3086 3087 3088 3089 3090 3091 3092 3093 3094 3095 3096 3097 3098 3099 3100 3101 3102 3103 3104 3105 3106 3107 3108 3109 3110 3111 3112 3113 3114 3115 3116 3117 3118 3119 3120 3121 3122 3123 3124 3125 3126 3127 3128 3129 3130 3131 3132 3133 3134 3135 3136 3137 3138 3139 3140 3141 3142 3143 3144 3145 3146 3147 3148 3149 3150 3151 3152 3153 3154 3155 3156 3157 3158 3159 3160 3161 3162 3163 3164 3165 3166 3167 3168 3169 3170 3171 3172 3173 3174 3175 3176 3177 3178 3179 3180 3181 3182 3183 3184 3185 3186 3187 3188 3189 3190 3191 3192 3193 3194 3195 3196 3197 3198 3199 3200 3201 3202 3203 3204 3205 3206 3207 3208 3209 3210 3211 3212 3213 3214 3215 3216 3217 3218 3219 3220 3221 3222 3223 3224 3225 3226 3227 3228 3229 3230 3231 3232 3233 3234 3235 3236 3237 3238 3239 3240 3241 3242 3243 3244 3245 3246 3247 3248 3249 3250 3251 3252 3253 3254 3255 3256 3257 3258 3259 3260 3261 3262 3263 3264 3265 3266 3267 3268 3269 3270 3271 3272 3273 3274 3275 3276 3277 3278 3279 3280 3281 3282 3283 3284 3285 3286 3287 3288 3289 3290 3291 3292 3293 3294 3295 3296 3297 3298 3299 3300 3301 3302 3303 3304 3305 3306 3307 3308 3309 3310 3311 3312 3313 3314 3315 3316 3317 3318 3319 3320 3321 3322 3323 3324 3325 3326 3327 3328 3329 3330 3331 3332 3333 3334 3335 3336 3337 3338 3339 3340 3341 3342 3343 3344 3345 3346 3347 3348 3349 3350 3351 3352 3353 3354 3355 3356 3357 3358 3359 3360 3361 3362 3363 3364 3365 3366 3367 3368 3369 3370 3371 3372 3373 3374 3375 3376 3377 3378 3379 3380 3381 3382 3383 3384 3385 3386 3387 3388 3389 3390 3391 3392 3393 3394 3395 3396 3397 3398 3399 3400 3401 3402 3403 3404 3405 3406 3407 3408 3409 3410 3411 3412 3413 3414 3415 3416 3417 3418 3419 3420 3421 3422 3423 3424 3425 3426 3427 3428 3429 3430 3431 3432 3433 3434 3435 3436 3437 3438 3439 3440 3441 3442 3443 3444 3445 3446 3447 3448 3449 3450 3451 3452 3453 3454 3455 3456 3457 3458 3459 3460 3461 3462 3463 3464 3465 3466 3467 3468 3469 3470 3471 3472 3473 3474 3475 3476 3477 3478 3479 3480 3481 3482 3483 3484 3485 3486 3487 3488 3489 3490 3491 3492 3493 3494 3495 3496 3497 3498 3499 3500 3501 3502 3503 3504 3505 3506 3507 3508 3509 3510 3511 3512 3513 3514 3515 3516 3517 3518 3519 3520 3521 3522 3523 3524 3525 3526 3527 3528 3529 3530 3531 3532 3533 3534 3535 3536 3537 3538 3539 3540 3541 3542 3543 3544 3545 3546 3547 3548 3549 3550 3551 3552 3553 3554 3555 3556 3557 3558 3559 3560 3561 3562 3563 3564 3565 3566 3567 3568 3569 3570 3571 3572 3573 3574 3575 3576 3577 3578 3579 3580 3581 3582 3583 3584 3585 3586 3587 3588 3589 3590 3591 3592 3593 3594 3595 3596 3597 3598 3599 3600 3601 3602 3603 3604 3605 3606 3607 3608 3609 3610 3611 3612 3613 3614 3615 3616 3617 3618 3619 3620 3621 3622 3623 3624 3625 3626 3627 3628 3629 3630 3631 3632 3633 3634 3635 3636 3637 3638 3639 3640 3641 3642 3643 3644 3645 3646 3647 3648 3649 3650 3651 3652 3653 3654 3655 3656 3657 3658 3659 3660 3661 3662 3663 3664 3665 3666 3667 3668 3669 3670 3671 3672 3673 3674 3675 3676 3677 3678 3679 3680 3681 3682 3683 3684 3685 3686 3687 3688 3689 3690 3691 3692 3693 3694 3695 3696 3697 3698 3699 3700 3701 3702 3703 3704 3705 3706 3707 3708 3709 3710 3711 3712 3713 3714 3715 3716 3717 3718 3719 3720 3721 3722 3723 3724 3725 3726 3727 3728 3729 3730 3731 3732 3733 3734 3735 3736 3737 3738 3739 3740 3741 3742 3743 3744 3745 3746 3747 3748 3749 3750 3751 3752 3753 3754 3755 3756 3757 3758 3759 3760 3761 3762 3763 3764 3765 3766 3767 3768 3769 3770 3771 3772 3773 3774 3775 3776 3777 3778 3779 3780 3781 3782 3783 3784 3785 3786 3787 3788 3789 3790 3791 3792 3793 3794 3795 3796 3797 3798 3799 3800 3801 3802 3803 3804 3805 3806 3807 3808 3809 3810 3811 3812 3813 3814 3815 3816 3817 3818 3819 3820 3821 3822 3823 3824 3825 3826 3827 3828 3829 3830 3831 3832 3833 3834 3835 3836 3837 3838 3839 3840 3841 3842 3843 3844 3845 3846 3847 3848 3849 3850 3851 3852 3853 3854 3855 3856 3857 3858 3859 3860 3861 3862 3863 3864 3865 3866 3867 3868 3869 3870 3871 3872 3873 3874 3875 3876 3877 3878 3879 3880 3881 3882 3883 3884 3885 3886 3887 3888 3889 3890 3891 3892 3893 3894 3895 3896 3897 3898 3899 3900 3901 3902 3903 3904 3905 3906 3907 3908 3909 3910 3911 3912 3913 3914 3915 3916 3917 3918 3919 3920 3921 3922 3923 3924 3925 3926 3927 3928 3929 3930 3931 3932 3933 3934 3935 3936 3937 3938 3939 3940 3941 3942 3943 3944 3945 3946 3947 3948 3949 3950 3951 3952 3953 3954 3955 3956 3957 3958 3959 3960 3961 3962 3963 3964 3965 3966 3967 3968 3969 3970 3971 3972 3973 3974 3975 3976 3977 3978 3979 3980 3981 3982 3983 3984 3985 3986 3987 3988 3989 3990 3991 3992 3993 3994 3995 3996 3997 3998 3999 4000 4001 4002 4003 4004 4005 4006 4007 4008 4009 4010 4011 4012 4013 4014 4015 4016 4017 4018 4019 4020 4021 4022 4023 4024 4025 4026 4027 4028 4029 4030 4031 4032 4033 4034 4035 4036 4037 4038 4039 4040 4041 4042 4043 4044 4045 4046 4047 4048 4049 4050 4051 4052 4053 4054 4055 4056 4057 4058 4059 4060 4061 4062 4063 4064 4065 4066 4067 4068 4069 4070 4071 4072 4073 4074 4075 4076 4077 4078 4079 4080 4081 4082 4083 4084 4085 4086 4087 4088 4089 4090 4091 4092 4093 4094 4095 4096 4097 4098 4099 4100 4101 4102 4103 4104 4105 4106 4107 4108 4109 4110 4111 4112 4113 4114 4115 4116 4117 4118 4119 4120 4121 4122 4123 4124 4125 4126 4127 4128 4129 4130 4131 4132 4133 4134 4135 4136 4137 4138 4139 4140 4141 4142 4143 4144 4145 4146 4147 4148 4149 4150 4151 4152 4153 4154 4155 4156 4157 4158 4159 4160 4161 4162 4163 4164 4165 4166 4167 4168 4169 4170 4171 4172 4173 4174 4175 4176 4177 4178 4179 4180 4181 4182 4183 4184 4185 4186 4187 4188 4189 4190 4191 4192 4193 4194 4195 4196 4197 4198 4199 4200 4201 4202 4203 4204 4205 4206 4207 4208 4209 4210 4211 4212 4213 4214 4215 4216 4217 4218 4219 4220 4221 4222 4223 4224 4225 4226 4227 4228 4229 4230 4231 4232 4233 4234 4235 4236 4237 4238 4239 4240 4241 4242 4243 4244 4245 4246 4247 4248 4249 4250 4251 4252 4253 4254 4255 4256 4257 4258 4259 4260 4261 4262 4263 4264 4265 4266 4267 4268 4269 4270 4271 4272 4273 4274 4275 4276 4277 4278 4279 4280 4281 4282 4283 4284 4285 4286 4287 4288 4289 4290 4291 4292 4293 4294 4295 4296 4297 4298 4299 4300 4301 4302 4303 4304 4305 4306 4307 4308 4309 4310 4311 4312 4313 4314 4315 4316 4317 4318 4319 4320 4321 4322 4323 4324 4325 4326 4327 4328 4329 4330 4331 4332 4333 4334 4335 4336 4337 4338 4339 4340 4341 4342 4343 4344 4345 4346 4347 4348 4349 4350 4351 4352 4353 4354 4355 4356 4357 4358 4359 4360 4361 4362 4363 4364 4365 4366 4367 4368 4369 4370 4371 4372 4373 4374 4375 4376 4377 4378 4379 4380 4381 4382 4383 4384 4385 4386 4387 4388 4389 4390 4391 4392 4393 4394 4395 4396 4397 4398 4399 4400 4401 4402 4403 4404 4405 4406 4407 4408 4409 4410 4411 4412 4413 4414 4415 4416 4417 4418 4419 4420 4421 4422 4423 4424 4425 4426 4427 4428 4429 4430 4431 4432 4433 4434 4435 4436 4437 4438 4439 4440 4441 4442 4443 4444 4445 4446 4447 4448 4449 4450 4451 4452 4453 4454 4455 4456 4457 4458 4459 4460 4461 4462 4463 4464 4465 4466 4467 4468 4469 4470 4471 4472 4473 4474 4475 4476 4477 4478 4479 4480 4481 4482 4483 4484 4485 4486 4487 4488 4489 4490 4491 4492 4493 4494 4495 4496 4497 4498 4499 4500 4501 4502 4503 4504 4505 4506 4507 4508 4509 4510 4511 4512 4513 4514 4515 4516 4517 4518 4519 4520 4521 4522 4523 4524 4525 4526 4527 4528 4529 4530 4531 4532 4533 4534 4535 4536 4537 4538 4539 4540 4541 4542 4543 4544 4545 4546 4547 4548 4549 4550 4551 4552 4553 4554 4555 4556 4557 4558 4559 4560 4561 4562 4563 4564 4565 4566 4567 4568 4569 4570 4571 4572 4573 4574 4575 4576 4577 4578 4579 4580 4581 4582 4583 4584 4585 4586 4587 4588 4589 4590 4591 4592 4593 4594 4595 4596 4597 4598 4599 4600 4601 4602 4603 4604 4605 4606 4607 4608 4609 4610 4611 4612 4613 4614 4615 4616 4617 4618 4619 4620 4621 4622 4623 4624 4625 4626 4627 4628 4629 4630 4631 4632 4633 4634 4635 4636 4637 4638 4639 4640 4641 4642 4643 4644 4645 4646 4647 4648 4649 4650 4651 4652 4653 4654 4655 4656 4657 4658 4659 4660 4661 4662 4663 4664 4665 4666 4667 4668 4669 4670 4671 4672 4673 4674 4675 4676 4677 4678 4679 4680 4681 4682 4683 4684 4685 4686 4687 4688 4689 4690 4691 4692 4693 4694 4695 4696 4697 4698 4699 4700 4701 4702 4703 4704 4705 4706 4707 4708 4709 4710 4711 4712 4713 4714 4715 4716 4717 4718 4719 4720 4721 4722 4723 4724 4725 4726 4727 4728 4729 4730 4731 4732 4733 4734 4735 4736 4737 4738 4739 4740 4741 4742 4743 4744 4745 4746 4747 4748 4749 4750 4751 4752 4753 4754 4755 4756 4757 4758 4759 4760 4761 4762 4763 4764 4765 4766 4767 4768 4769 4770 4771 4772 4773 4774 4775 4776 4777 4778 4779 4780 4781 4782 4783 4784 4785 4786 4787 4788 4789 4790 4791 4792 4793 4794 4795 4796 4797 4798 4799 4800 4801 4802 4803 4804 4805 4806 4807 4808 4809 4810 4811 4812 4813 4814 4815 4816 4817 4818 4819 4820 4821 4822 4823 4824 4825 4826 4827 4828 4829 4830 4831 4832 4833 4834 4835 4836 4837 4838 4839 4840 4841 4842 4843 4844 4845 4846 4847 4848 4849 4850 4851 4852 4853 4854 4855 4856 4857 4858 4859 4860 4861 4862 4863 4864 4865 4866 4867 4868 4869 4870 4871 4872 4873 4874 4875 4876 4877 4878 4879 4880 4881 4882 4883 4884 4885 4886 4887 4888 4889 4890 4891 4892 4893 4894 4895 4896 4897 4898 4899 4900 4901 4902 4903 4904 4905 4906 4907 4908 4909 4910 4911 4912 4913 4914 4915 4916 4917 4918 4919 4920 4921 4922 4923 4924 4925 4926 4927 4928 4929 4930 4931 4932 4933 4934 4935 4936 4937 4938 4939 4940 4941 4942 4943 4944 4945 4946 4947 4948 4949 4950 4951 4952 4953 4954 4955 4956 4957 4958 4959 4960 4961 4962 4963 4964 4965 4966 4967 4968 4969 4970 4971 4972 4973 4974 4975 4976 4977 4978 4979 4980 4981 4982 4983 4984 4985 4986 4987 4988 4989 4990 4991 4992 4993 4994 4995 4996 4997 4998 4999 5000 5001 5002 5003 5004 5005 5006 5007 5008 5009 5010 5011 5012 5013 5014 5015 5016 5017 5018 5019 5020 5021 5022 5023 5024 5025 5026 5027 5028 5029 5030 5031 5032 5033 5034 5035 5036 5037 5038 5039 5040 5041 5042 5043 5044 5045 5046 5047 5048 5049 5050 5051 5052 5053 5054 5055 5056 5057 5058 5059 5060 5061 5062 5063 5064 5065 5066 5067 5068 5069 5070 5071 5072 5073 5074 5075 5076 5077 5078 5079 5080 5081 5082 5083 5084 5085 5086 5087 5088 5089 5090 5091 5092 5093 5094 5095 5096 5097 5098 5099 5100 5101 5102 5103 5104 5105 5106 5107 5108 5109 5110 5111 5112 5113 5114 5115 5116 5117 5118 5119 5120 5121 5122 5123 5124 5125 5126 5127 5128 5129 5130 5131 5132 5133 5134 5135 5136 5137 5138 5139 5140 5141 5142 5143 5144 5145 5146 5147 5148 5149 5150 5151 5152 5153 5154 5155 5156 5157 5158 5159 5160 5161 5162 5163 5164 5165 5166 5167 5168 5169 5170 5171 5172 5173 5174 5175 5176 5177 5178 5179 5180 5181 5182 5183 5184 5185 5186 5187 5188 5189 5190 5191 5192 5193 5194 5195 5196 5197 5198 5199 5200 5201 5202 5203 5204 5205 5206 5207 5208 5209 5210 5211 5212 5213 5214 5215 5216 5217 5218 5219 5220 5221 5222 5223 5224 5225 5226 5227 5228 5229 5230 5231 5232 5233 5234 5235 5236 5237 5238 5239 5240 5241 5242 5243 5244 5245 5246 5247 5248 5249 5250 5251 5252 5253 5254 5255 5256 5257 5258 5259 5260 5261 5262 5263 5264 5265 5266 5267 5268 5269 5270 5271 5272 5273 5274 5275 5276 5277 5278 5279 5280 5281 5282 5283 5284 5285 5286 5287 5288 5289 5290 5291 5292 5293 5294 5295 5296 5297 5298 5299 5300 5301 5302 5303 5304 5305 5306 5307 5308 5309 5310 5311 5312 5313 5314 5315 5316 5317 5318 5319 5320 5321 5322 5323 5324 5325 5326 5327 5328 5329 5330 5331 5332 5333 5334 5335 5336 5337 5338 5339 5340 5341 5342 5343 5344 5345 5346 5347 5348 5349 5350 5351 5352 5353 5354 5355 5356 5357 5358 5359 5360 5361 5362 5363 5364 5365 5366 5367 5368 5369 5370 5371 5372 5373 5374 5375 5376 5377 5378 5379 5380 5381 5382 5383 5384 5385 5386 5387 5388 5389 5390 5391 5392 5393 5394 5395 5396 5397 5398 5399 5400 5401 5402 5403 5404 5405 5406 5407 5408 5409 5410 5411 5412 5413 5414 5415 5416 5417 5418 5419 5420 5421 5422 5423 5424 5425 5426 5427 5428 5429 5430 5431 5432 5433 5434 5435 5436 5437 5438 5439 5440 5441 5442 5443 5444 5445 5446 5447 5448 5449 5450 5451 5452 5453 5454 5455 5456 5457 5458 5459 5460 5461 5462 5463 5464 5465 5466 5467 5468 5469 5470 5471 5472 5473 5474 5475 5476 5477 5478 5479 5480 5481 5482 5483 5484 5485 5486 5487 5488 5489 5490 5491 5492 5493 5494 5495 5496 5497 5498 5499 5500 5501 5502 5503 5504 5505 5506 5507 5508 5509 5510 5511 5512 5513 5514 5515 5516 5517 5518 5519 5520 5521 5522 5523 5524 5525 5526 5527 5528 5529 5530 5531 5532 5533 5534 5535 5536 5537 5538 5539 5540 5541 5542 5543 5544 5545 5546 5547 5548 5549 5550 5551 5552 5553 5554 5555 5556 5557 5558 5559 5560 5561 5562 5563 5564 5565 5566 5567 5568 5569 5570 5571 5572 5573 5574 5575 5576 5577 5578 5579 5580 5581 5582 5583 5584 5585 5586 5587 5588 5589 5590 5591 5592 5593 5594 5595 5596 5597 5598 5599 5600 5601 5602 5603 5604 5605 5606 5607 5608 5609 5610 5611 5612 5613 5614 5615 5616 5617 5618 5619 5620 5621 5622 5623 5624 5625 5626 5627 5628 5629 5630 5631 5632 5633 5634 5635 5636 5637 5638 5639 5640 5641 5642 5643 5644 5645 5646 5647 5648 5649 5650 5651 5652 5653 5654 5655 5656 5657 5658 5659 5660 5661 5662 5663 5664 5665 5666 5667 5668 5669 5670 5671 5672 5673 5674 5675 5676 5677 5678 5679 5680 5681 5682 5683 5684 5685 5686 5687 5688 5689 5690 5691 5692 5693 5694 5695 5696 5697 5698 5699 5700 5701 5702 5703 5704 5705 5706 5707 5708 5709 5710 5711 5712 5713 5714 5715 5716 5717 5718 5719 5720 5721 5722 5723 5724 5725 5726 5727 5728 5729 5730 5731 5732 5733 5734 5735 5736 5737 5738 5739 5740 5741 5742 5743 5744 5745 5746 5747 5748 5749 5750 5751 5752 5753 5754 5755 5756 5757 5758 5759 5760 5761 5762 5763 5764 5765 5766 5767 5768 5769 5770 5771 5772 5773 5774 5775 5776 5777 5778 5779 5780 5781 5782 5783 5784 5785 5786 5787 5788 5789 5790 5791 5792 5793 5794 5795 5796 5797 5798 5799 5800 5801 5802 5803 5804 5805 5806 5807 5808 5809 5810 5811 5812 5813 5814 5815 5816 5817 5818 5819 5820 5821 5822 5823 5824 5825 5826 5827 5828 5829 5830 5831 5832 5833 5834 5835 5836 5837 5838 5839 5840 5841 5842 5843 5844 5845 5846 5847 5848 5849 5850 5851 5852 5853 5854 5855 5856 5857 5858 5859 5860 5861 5862 5863 5864 5865 5866 5867 5868 5869 5870 5871 5872 5873 5874 5875 5876 5877 5878 5879 5880 5881 5882 5883 5884 5885 5886 5887 5888 5889 5890 5891 5892 5893 5894 5895 5896 5897 5898 5899 5900 5901 5902 5903 5904 5905 5906 5907 5908 5909 5910 5911 5912 5913 5914 5915 5916 5917 5918 5919 5920 5921 5922 5923 5924 5925 5926 5927 5928 5929 5930 5931 5932 5933 5934 5935 5936 5937 5938 5939 5940 5941 5942 5943 5944 5945 5946 5947 5948 5949 5950 5951 5952 5953 5954 5955 5956 5957 5958 5959 5960 5961 5962 5963 5964 5965 5966 5967 5968 5969 5970 5971 5972 5973 5974 5975 5976 5977 5978 5979 5980 5981 5982 5983 5984 5985 5986 5987 5988 5989 5990 5991 5992 5993 5994 5995 5996 5997 5998 5999 6000 6001 6002 6003 6004 6005 6006 6007 6008 6009 6010 6011 6012 6013 6014 6015 6016 6017 6018 6019 6020 6021 6022 6023 6024 6025 6026 6027 6028 6029 6030 6031 6032 6033 6034 6035 6036 6037 6038 6039 6040 6041 6042 6043 6044 6045 6046 6047 6048 6049 6050 6051 6052 6053 6054 6055 6056 6057 6058 6059 6060 6061 6062 6063 6064 6065 6066 6067 6068 6069 6070 6071 6072 6073 6074 6075 6076 6077 6078 6079 6080 6081 6082 6083 6084 6085 6086 6087 6088 6089 6090 6091 6092 6093 6094 6095 6096 6097 6098 6099 6100 6101 6102 6103 6104 6105 6106 6107 6108 6109 6110 6111 6112 6113 6114 6115 6116 6117 6118 6119 6120 6121 6122 6123 6124 6125 6126 6127 6128 6129 6130 6131 6132 6133 6134 6135 6136 6137 6138 6139 6140 6141 6142 6143 6144 6145 6146 6147 6148 6149 6150 6151 6152 6153 6154 6155 6156 6157 6158 6159 6160 6161 6162 6163 6164 6165 6166 6167 6168 6169 6170 6171 6172 6173 6174 6175 6176 6177 6178 6179 6180 6181 6182 6183 6184 6185 6186 6187 6188 6189 6190 6191 6192 6193 6194 6195 6196 6197 6198 6199 6200 6201 6202 6203 6204 6205 6206 6207 6208 6209 6210 6211 6212 6213 6214 6215 6216 6217 6218 6219 6220 6221 6222 6223 6224 6225 6226 6227 6228 6229 6230 6231 6232 6233 6234 6235 6236 6237 6238 6239 6240 6241 6242 6243 6244 6245 6246 6247 6248 6249 6250 6251 6252 6253 6254 6255 6256 6257 6258 6259 6260 6261 6262 6263 6264 6265 6266 6267 6268 6269 6270 6271 6272 6273 6274 6275 6276 6277 6278 6279 6280 6281 6282 6283 6284 6285 6286 6287 6288 6289 6290 6291 6292 6293 6294 6295 6296 6297 6298 6299 6300 6301 6302 6303 6304 6305 6306 6307 6308 6309 6310 6311 6312 6313 6314 6315 6316 6317 6318 6319 6320 6321 6322 6323 6324 6325 6326 6327 6328 6329 6330 6331 6332 6333 6334 6335 6336 6337 6338 6339 6340 6341 6342 6343 6344 6345 6346 6347 6348 6349 6350 6351 6352 6353 6354 6355 6356 6357 6358 6359 6360 6361 6362 6363 6364 6365 6366 6367 6368 6369 6370 6371 6372 6373 6374 6375 6376 6377 6378 6379 6380 6381 6382 6383 6384 6385 6386 6387 6388 6389 6390 6391 6392 6393 6394 6395 6396 6397 6398 6399 6400 6401 6402 6403 6404 6405 6406 6407 6408 6409 6410 6411 6412 6413 6414 6415 6416 6417 6418 6419 6420 6421 6422 6423 6424 6425 6426 6427 6428 6429 6430 6431 6432 6433 6434 6435 6436 6437 6438 6439 6440 6441 6442 6443 6444 6445 6446 6447 6448 6449 6450 6451 6452 6453 6454 6455 6456 6457 6458 6459 6460 6461 6462 6463 6464 6465 6466 6467 6468 6469 6470 6471 6472 6473 6474 6475 6476 6477 6478 6479 6480 6481 6482 6483 6484 6485 6486 6487 6488 6489 6490 6491 6492 6493 6494 6495 6496 6497 6498 6499 6500 6501 6502 6503 6504 6505 6506 6507 6508 6509 6510 6511 6512 6513 6514 6515 6516 6517 6518 6519 6520 6521 6522 6523 6524 6525 6526 6527 6528 6529 6530 6531 6532 6533 6534 6535 6536 6537 6538 6539 6540 6541 6542 6543 6544 6545 6546 6547 6548 6549 6550 6551 6552 6553 6554 6555 6556 6557 6558 6559 6560 6561 6562 6563 6564 6565 6566 6567 6568 6569 6570 6571 6572 6573 6574 6575 6576 6577 6578 6579 6580 6581 6582 6583 6584 6585 6586 6587 6588 6589 6590 6591 6592 6593 6594 6595 6596 6597 6598 6599 6600 6601 6602 6603 6604 6605 6606 6607 6608 6609 6610 6611 6612 6613 6614 6615 6616 6617 6618 6619 6620 6621 6622 6623 6624 6625 6626 6627 6628 6629 6630 6631 6632 6633 6634 6635 6636 6637 6638 6639 6640 6641 6642 6643 6644 6645 6646 6647 6648 6649 6650 6651 6652 6653 6654 6655 6656 6657 6658 6659 6660 6661 6662 6663 6664 6665 6666 6667 6668 6669 6670 6671 6672 6673 6674 6675 6676 6677 6678 6679 6680 6681 6682 6683 6684 6685 6686 6687 6688 6689 6690 6691 6692 6693 6694 6695 6696 6697 6698 6699 6700 6701 6702 6703 6704 6705 6706 6707 6708 6709 6710 6711 6712 6713 6714 6715 6716 6717 6718 6719 6720 6721 6722 6723 6724 6725 6726 6727 6728 6729 6730 6731 6732 6733 6734 6735 6736 6737 6738 6739 6740 6741 6742 6743 6744 6745 6746 6747 6748 6749 6750 6751 6752 6753 6754 6755 6756 6757 6758 6759 6760 6761 6762 6763 6764 6765 6766 6767 6768 6769 6770 6771 6772 6773 6774 6775 6776 6777 6778 6779 6780 6781 6782 6783 6784 6785 6786 6787 6788 6789 6790 6791 6792 6793 6794 6795 6796 6797 6798 6799 6800 6801 6802 6803 6804 6805 6806 6807 6808 6809 6810 6811 6812 6813 6814 6815 6816 6817 6818 6819 6820 6821 6822 6823 6824 6825 6826 6827 6828 6829 6830 6831 6832 6833 6834 6835 6836 6837 6838 6839 6840 6841 6842 6843 6844 6845 6846 6847 6848 6849 6850 6851 6852 6853 6854 6855 6856 6857 6858 6859 6860 6861 6862 6863 6864 6865 6866 6867 6868 6869 6870 6871 6872 6873 6874 6875 6876 6877 6878 6879 6880 6881 6882 6883 6884 6885 6886 6887 6888 6889 6890 6891 6892 6893 6894 6895 6896 6897 6898 6899 6900 6901 6902 6903 6904 6905 6906 6907 6908 6909 6910 6911 6912 6913 6914 6915 6916 6917 6918 6919 6920 6921 6922 6923 6924 6925 6926 6927 6928 6929 6930 6931 6932 6933 6934 6935 6936 6937 6938 6939 6940 6941 6942 6943 6944 6945 6946 6947 6948 6949 6950 6951 6952 6953 6954 6955 6956 6957 6958 6959 6960 6961 6962 6963 6964 6965 6966 6967 6968 6969 6970 6971 6972 6973 6974 6975
|
# construct a FitsTable object # FitsTable FitsTableObjName FitsFileObjName currentHDU
#-------------------------------------------------------------------------------
# Modification History:
# Ziqin Pan, Feb 18, 2004
# Add the following row selection functions
# 1. Select rows by using the mouse
# 2. Select all rows
# 3. Invert selected rows
# 4. Select rows from expr
# 5. Delete the selected rows
# 6. Do statistics on selected rows
# 7. Do histogram on selected rows
# 8. Calculate value on selected rows and column
# 9. Keep selected rows after doing sorting
# 10. Export selected rows and columns as text
# 11. Export selected rows and columns as HDU
#-------------------------------------------------------------------------------
itcl::class Table {
constructor {args} {}
destructor {}
public method makeTable { extNum_ }
public method refresh { {doChildren_ 1} }
public method calculateCols {colname_ colform_ formula_ selonly_}
public method getCalcCols {}
public method scplotCmd {{xyname_ {}}}
public method delRowsWithCondition {cond_}
public method selRowsWithCondition {cond_ fRow_ nRows_ seland_ selor_}
public method delRowsFromList {entry_}
public method selRowsFromList {entry_ seland_ selor_}
public method closeCmd {}
public method bringToFront {}
public method setFileName { fName_ }
public method addChild { child_ }
public method freeChild { child_ }
public method callHistogramDirectly { extNum_ fillFlag_ }
public method getColInfo { name } { return [$fFile getColInfo $name] }
# used by VectorTable
public method getFatherFitsExtension {}
public method getColumnInfo {name_ index_}
# see protected sort methods below
public method doSort { keys_ dirs_ unique_ }
# called within VectorTable's constructor
public method passParamsToVectorTable {}
public method getnumRows {}
public variable fileName ""
public variable isFailedToCopy 0
public variable fFile
public variable currentHDU
public method trySaveASCII {}
public method tryExport {}
# protected
protected variable _extNum 1
protected variable snum ""
protected variable _overWriteImageValue
protected variable _neverAskFlagValue "false"
protected variable _overWriteImage no
protected variable _frameXPos
protected variable _endX 0
protected variable _valueTDIM
protected variable _istart 0
protected variable _iend 0
protected variable _opCancel "false"
protected method _determineOverWriteFlag {}
protected method _openGroupFile { c r }
protected method _plotVectorTableRow { c r }
protected method _ds9MakeImage { fh colIdx slice xSize ySize }
protected method _ds9MakePlot { rowNum_ fRow lRow xColumn_ yColumn_ {xeColumn_ ""} {yeColumn_ ""} }
protected method _ds9MakePlot1 { rowNum_ range xColumn_ yColumn_ {xeColumn_ ""} {yeColumn_ ""} {inCurrGraph_ 0}}
protected method _setOverWriteFlag { }
protected method _setOpCancel { }
protected method _drawTable {}
protected method _plotCmd {}
protected method _plotCols { xColumn_ xeColumn_ yColumn_ yeColumn_ \
{inCurrGraph_ 0} {whichRows_ -} {plotSelOnly_ 0}}
protected method _drawTableFrame {}
protected method _getDataForAxis { axis_ axisExpression_ rows_ }
protected method _relocateDividLine {x_ index_}
protected method _finalDividLine {x_ index_}
protected method _startDividLine {x_ index_}
protected method _setVScroll {args}
protected method _setHScroll {args}
protected method _setupTable { }
protected method _redrawTable {prevCols_}
protected method _addColsToTable {prevCols_ prevRows_}
protected method _delColsFrTable {prevCols_ prevRows_}
protected method _addRowsToTable {prevCols_ prevRows_}
protected method _delRowsFrTable {prevCols_ prevRows_}
protected method _addColsToFile {inWin_}
protected method _addRowsToFile {inWin_}
protected method _updateLast { }
protected method _colMenu { hdr i colName colNum }
protected method _updateUnViewedColumns {}
protected method _moveColView { colName targetName option }
protected method _addColView { colName_ addPos_ beforeAfter_ }
protected method _delColView { colName_ }
protected method _editColParamsWindow { { colNum0_ 0 } }
protected method _isVScrollLocked {}
private variable _isVScrollLocked1
protected method _scrollChildren { firstRow { currentRow -1} }
################
# Subclasses need to implement these methods...
# all col/row params are zero-based
protected method _getRawData {col_ row_}
protected method _getFormattedData {col_ row_}
protected method _readTableData {fCol_ fRow_ nCols_ nRows_}
protected method _getRawDataBlock {fCol_ fRow_ lCol_ lRow_}
protected method _putRawDataBlock {fCol_ fRow_ data_}
protected method _putRawData {fCol_ fRow_ val_}
#
################
protected method _jumpFrEnt {}
protected method _jump {lineNum_}
protected method _selRowsFrExpr {ifDelete_}
protected method _copyCell {col_ row_}
protected method _modifyTableCell {col_ row_ val_}
protected method _writeTableData {col_ row_ val_}
protected method _updateColSel {col_}
protected method _resizeCan {x_ y_}
protected method _layoutCan {x_ y_}
protected method _getXYSize {x_ y_}
protected method _refacing {}
protected method _saveAs {}
# exports to ascii file
protected method _saveASCII {}
protected method _export {}
protected method _calXPos {fCol_ nCols_}
protected method _reframe {}
protected method _setScrolls {}
protected method _getLastFirstCol {}
protected method _closeFrWm {w_}
protected method _realCloseCmd {}
protected method _saveFile {}
protected method _updateNumRows {}
protected method _updateNumCols {}
# protected method _addCols {}
public method _addCols {{colindex -1 } {colname {} } {colformat {}} { colunit {}} {dispformat {}} }
# protected method _delCols {}
protected method _delCols {{collist_ -1 }}
protected method _delRows {}
protected method _delRowsRange {}
# protected method _tryDelCols {}
public method _tryDelCols {{collist_ -1 }}
# protected method _tryDelRows {}
public method _tryDelRows {{range_ 0}}
# protected method _addRows {}
public method _addRows {{rowindex -1} {rownum -1}}
protected method _openVectorTable { colNum_ }
# Ziqin Pan, Jan 2004
# Added functions for rows selection
protected method _initSelRows {}
protected method _selAllRows {}
protected method _selRows {}
public method _showselRows {}
public method _showselCheck {}
protected method _logicalWithselectedRows {rowlist_ seland_ selor_}
protected method _setRowStartMark { row_}
protected method _setRowEndMark { row_}
protected method _unsetRowMark {}
protected method _selInvert {}
protected method _updateExportPanelState {}
protected method _writeHist {ffile_ origName_}
public method _parseToRowRange {start_end}
protected method _saveTableToFile {win_ fitsFileName_ origName_}
#
#
protected method _editCell {}
protected method _selCell {}
protected method _unselCell {}
protected method _cellUp {}
protected method _cellDown {}
protected method _cellLeft {}
protected method _cellRight {}
protected method _pageUp {}
protected method _pageDown {}
protected method _jumpTo { colName }
protected method _calculateCmd {}
protected method _collapse {seed_ bed_}
protected method _sortRange {bed_}
protected method _sortCmd {}
protected method _sortColumn {}
protected method _calAbsXPos {}
protected method _determineRealSlice { slice }
protected method _getSortKey {key_}
protected method _resetSKey {}
protected method _cpyToCB {}
protected method _cpyFrCB {}
protected method _displaySlice { colIdx slice }
protected method _createMovie { colIdx slice xSize ySize }
protected method _getKeywordValue { keyword header }
protected method _displayMovie { colIdx slice }
protected method _makeHistogram { {extNum_ {}} }
protected method _histoCmd {}
protected method _changeUniqLabel {}
protected method _statCmd {}
protected method _statSelCmd {}
protected method _makeJustification {}
protected method _updateRestDisps {}
protected method _saveTableToAscii {win_ asciiFileName_}
protected method _setStartMark {col_ row_ {focus True} }
protected method _buildMenus {}
protected method _buildNewMenus {}
protected method _postMenus {}
protected method _updateHL {}
protected common _colSel
protected common _asciiColWidth 80
protected common _psortkey
protected common _ssortkey
protected common _tsortkey
protected common _psortcheck 1
protected common _ssortcheck 1
protected common _tsortcheck 1
protected common _addcolname ""
protected common _addcolunit ""
protected common _addcolform ""
protected common _addcoldisp ""
protected common _isUniqMerge 0
# this explains the format for _numEntry, which contains what actually
# shows up on the screen
# set id ${c}_${r}
# set _numEntry($id) $val
protected variable _arrayDim
protected variable _ttype
protected variable _tType
protected variable _numEntry
protected variable _currentCol
protected variable _currentRow
protected variable _cellVar
protected variable _cstartx ""
protected variable _cstarty ""
protected variable _oldcstartx ""
protected variable _oldcstarty ""
protected variable _cendx ""
protected variable _cendy ""
protected variable _insColNum "End of Table"
protected variable _showRows 20
protected variable _showCols 6
protected variable _firstRow 1
protected variable _firstCol 1
protected variable _old_firstCol 1
protected variable _lastFirstCol 1
protected variable _droot ""
protected variable _mBar
# Ziqin Pan, Jan 2004
# Add variables to support row selection
public variable _selectedRows
protected variable _rstart ""
protected variable _rend ""
protected variable _selectAllRows 0
protected variable _statselonly 0
protected variable _plotselonly 0
protected variable _calcselonly 0
protected variable _exportsel 0
protected variable _exportselc 0
protected variable _exportcolsel 0
protected variable _fth 0
protected variable _ftp 0
protected variable _rowindex 1
protected variable _rownum 1
#
#
# what does DC stand for?
protected variable _DC
protected variable _xPos
protected variable _yPos
protected variable _absXPos
protected variable _tableType
protected variable _numCols
protected variable _numRows
# arrays from 0 to $_dispCols - 1 that keep information on vector info
protected variable _cellPixWidth
# cell width in characters
protected variable _buttonWidth
protected variable _cellWidth
protected variable _columnName
protected variable _columnType
protected variable _columnComment
protected variable _columnUnit
protected variable _columnTDisp
protected variable _columnForm
protected variable _columnWidth
protected variable _columnNull
protected variable _columnDim
protected variable _columnVecSize
# a list (not an array) of column names
protected variable _listColNames
protected variable _unViewedColNames
# _rowState is NEVER used...I only keep it here because of fitsTcl
# (see fvTcl.c) -- Han
protected variable _rowState
# array of whether a column is chosen by the user ("notched" in the table display)
protected variable _colNotchedState
protected variable _tableData
protected variable _anyColSelected 0
protected variable _anyRowsSelected 0
# _listPreSelectedColNames is the list of columns preselected by user to be
# displayed using the right-mouse button on the Table button
protected variable _listPreSelectedColNames
protected variable _dispCols
protected variable _startX
protected variable _fatherFitsExtension
protected common _graphIDhighest 0
protected variable _isDirPlot 0
protected variable _justStarted 1
protected variable _isBeingDestroyed 0
protected variable _myChildren {}
protected method _readInTable { }
protected method _setEndMark {col_ row_}
protected method _unsetMark {}
# used only in statistics menu, see Table::_statCmd
protected common _colSName
protected common _colMin
protected common _colMax
protected common _colMean
protected common _colFMin
protected common _colFMax
protected common _colStd
protected common _colRowRange
protected common _colNumVal
# only used in the file export menu, see Table::_saveASCII
protected variable _exportRowRange
protected variable _exportFirstRow
protected variable _exportLastRow
protected variable _exportFirstCol
protected variable _exportLastCol
protected variable _exportPrintRowNumbers
protected variable _exportselRows
protected variable _exportFormat
protected variable _exportCSV
protected variable _exportUserChooseChar
protected variable _exportFixedFormat
protected variable _exportCharBetweenCols
protected variable _fitsFileLocationCol -1
protected variable _expandFlag false
protected variable sortRowResultList
}
itcl::body Table::constructor {args} {
}
itcl::body Table::destructor {} {
}
itcl::body Table::getnumRows {} {
return $_numRows
}
itcl::body Table::makeTable { extNum_ } {
global g_charPix
set _extNum $extNum_
set _DC(height) 20
# width in pixels required to display row numbers
# set _DC(width) [expr ($_numRows !=0 )? \
# (int(log10($_numRows))+4)*$g_charPix : 100 ]
set _DC(width) [expr ($_numRows > 10000 )? \
(int(log10($_numRows))+4)*$g_charPix : 8*$g_charPix ]
set _DC(headroom) 80
set _DC(footroom) 40
set _DC(vscrollsize) 15
set _DC(hscrollsize) 15
# space to the right of the data
set _DC(rightspace) 6
# space between lines
set _DC(interline) 0
# top margin
set _DC(tmar) 6
# left margin
set _DC(lmar) 8
# Whether vertical scrollers are locked to parent's
set _isVScrollLocked1 False
#Read in all the needed data
_readInTable
#Draw the table
_drawTable
_buildMenus
}
itcl::body Table::_readInTable { } {
#puts "readInTable start"
global g_charPix
set maxWidth [expr int([winfo screenwidth .]/$g_charPix)-10]
set _dispCols [llength $_listPreSelectedColNames]
for {set i 0} {$i < $_dispCols} {incr i} {
set tmpName [lindex $_listPreSelectedColNames $i]
if { [catch {set listOfListOneColInfo [$fFile getColInfo $tmpName]}] } {
# error, so we won't display the column
set _listPreSelectedColNames [lreplace $_listPreSelectedColNames $i $i]
incr i -1
incr _dispCols -1
} else {
set arrayColInfoLists($i) [lindex $listOfListOneColInfo 0]
}
}
setarray _colNotchedState 0 [expr $_dispCols-1] 0
set thisHeader [split [$fFile dumpHeader] \n]
for {set i 0} {$i < $_dispCols} {incr i} {
set _valueTDIM($i) 0
set listOneColInfo $arrayColInfoLists($i)
# in the listOneColInfo list. the elements are
# Index 0 : column name
# 1 : column type (TFORM)
# 2 : column unit
# 3 : column TDISP
# 4 : column format
# 5 : column width
# 6 : is Zero
# 7 : is Scaled
# 8 : column null value
#puts "listOneColInfo: $listOneColInfo"
set _columnName($i) [lindex $listOneColInfo 0]
# TFORM -- don't blame me, I didn't name this
# Pan Chai: ignore everything after the vaild TFORM value
# i.e., if TFORMn = 16A23:18/032
# TFORMn should be 16A23 only
set tformData [lindex $listOneColInfo 1]
regsub {^[0-9a-zA-Z]*} [lindex $listOneColInfo 1] "" restData
if { [string length $restData] > 0 } {
if { [string range $restData 0 0] == ":" } {
set idx [string first $restData $tformData]
set _columnType($i) [string range $tformData 0 [expr $idx - 1]]
} else {
set _columnType($i) [lindex $listOneColInfo 1]
}
} else {
set _columnType($i) [lindex $listOneColInfo 1]
}
# TUNIT
set _columnUnit($i) [lindex $listOneColInfo 2]
set _columnTDisp($i) [lindex $listOneColInfo 3]
set _columnComment($i) ""
set idx [lsearch -glob $thisHeader "TTYPE*$_columnName($i)*"]
if { $idx >= 0 } {
set commentTokenList [split [lindex $thisHeader $idx] "/"]
if { [llength $commentTokenList] > 1 } {
set _columnComment($i) [string trim [lindex $commentTokenList end]]
}
}
if { [regexp J $_columnType($i)] } {
set _columnForm($i) "%.10G"
} elseif { [regexp K $_columnType($i)] } {
# chai: K for 64 bits
set _columnForm($i) "%s"
} else {
set _columnForm($i) [lindex $listOneColInfo 4]
}
set _columnWidth($i) [lindex $listOneColInfo 5]
if { [regexp K $_columnType($i)] } {
# chai: using double data type width for the cell if it is K type
set _columnWidth($i) 20
}
set _columnNull($i) [lindex $listOneColInfo 8]
# Check for TDIM keyword
set colNo [lsearch $_listColNames $_columnName($i)]
incr colNo
if { [catch {set key [$fFile getKeyword TDIM$colNo]} err] } {
set _columnDim($i) 1
set _valueTDIM($i) 0
} else {
set key "[string trim [lindex [lindex $key 0] 1] {' ()}]"
set _columnDim($i) [split $key ,]
set _arrayDim($i) [split $key ,]
set _valueTDIM($i) [llength $_arrayDim($i)]
}
if { ![catch {set key [$fFile getKeyword TFORM$colNo]} err] } {
set key "[string trim [lindex [lindex $key 0] 1] {' ()}]"
set testKey $key
set value 1
scan $key "%d%s" value dataType
if { $value > 1 && [string range $dataType 0 0] != "A" &&
[string range $dataType 0 0] != "C" &&
[string range $dataType 0 0] != "L" &&
[string range $dataType 0 0] != "M" &&
[string range $dataType 0 0] != "P" &&
[string range $dataType 0 0] != "X" } {
if { $_valueTDIM($i) <= 0 } {
set _valueTDIM($i) 1
}
} else {
set testSequence [split $testKey "()"]
if { [llength $testSequence] != 2 } {
set _valueTDIM($i) 0
} else {
set idx [string first "P" [lindex $testSequence 0] ]
if { $idx >= 0 } {
regsub -all {[0-9]} [lindex $testSequence 1] "" result
if { $result != "" } {
set _valueTDIM($i) 0
}
} else {
set _valueTDIM($i) 0
}
}
}
}
if { ![catch {set _ttype [$fFile getKeyword TTYPE$colNo]} err] } {
set _ttype "[string trim [lindex [lindex $_ttype 0] 1] {' ()}]"
set _tType($i) [lindex [split $_ttype ,] 0]
}
# Determine vector size of column
if { $_tableType == "Binary Table" } {
# "PE(65)" means a variable vector table of max length 65
if { [string index $_columnType($i) end] == ")" } {
# remove letters PE
regsub -all {[A-Z]} $_columnType($i) "" _columnVecSize($i)
# Pull out variable length from (65)
if { ![regexp {\((.*)\)} $_columnVecSize($i) dmy val] } {
set val 0
}
set _columnVecSize($i) [expr -$val]
} else {
regsub -all {[A-Z].*} $_columnType($i) "" _columnVecSize($i)
# most common scenario; e.g., "F4.2" or "I"
if { $_columnVecSize($i) == "" } {
set _columnVecSize($i) 1
}
}
if { [regexp A $_columnType($i)] && $_columnVecSize($i) != 0 } {
set token [split $_columnType($i) "A"]
regsub -all {[A-Z]} [lindex $token 0] "" testString
if { $testString <= 1 } {
set _columnVecSize($i) 1
} elseif { [lindex $token 0] == "" && [lindex $token 1] == "" } {
set _columnVecSize($i) 1
} elseif { [lindex $token 1] == "" } {
set _columnVecSize($i) 1
# set _columnVecSize($i) [lindex $token 0]
} else {
set _columnVecSize($i) [expr [lindex $token 0] / [lindex $token 1]]
set _columnDim($i) [lindex $token 1]
set _columnWidth($i) [lindex $token 1]
}
}
} else {
set _columnVecSize($i) 1
}
if { ![info exists _cellWidth($i)] } {
set headMax 0
foreach l [list xx$_columnName($i) $_columnType($i) $_columnUnit($i)] {
set wdth [font measure g_titleFont $l]
if { $wdth > $headMax } {set headMax $wdth}
}
# we now have header maximum in pixels
set headMax [expr int( 1.0*$headMax/$g_charPix + 0.999 )]
# we now have header maximum in characters
set _cellWidth($i) [expr ($headMax > $_columnWidth($i)) \
? $headMax : $_columnWidth($i) ]
if { $_cellWidth($i) > $maxWidth } {
set _cellWidth($i) $maxWidth
}
}
}
_calAbsXPos
}
### why was this taken out? --Han
### I'm putting it back in (by uncommenting it)
#
itcl::body Table::_calAbsXPos {} {
#puts "_calAbsXPos start"
global g_charPix
set _absXPos(0) [expr $_DC(lmar) + $_DC(width) +$_DC(rightspace)]
# this is to determine the size of a button inside the entry
if ![winfo exists .dummyTest] {
button .dummyTest -text "WWWWW" -font [list Helvetica 10]
}
set _buttonSize [winfo reqwidth .dummyTest]
for {set i 0} {$i < $_dispCols} {incr i} {
set _cellPixWidth($i) [expr $g_charPix*$_cellWidth($i)+4]
set _absXPos([expr $i+1]) [expr $_absXPos($i)+$_cellPixWidth($i)+$_DC(rightspace) + 3]
if { $_valueTDIM($i) > 0 } {
# set _absXPos([expr $i+1]) [expr $_absXPos([expr $i + 1])+$_buttonSize]
}
}
}
itcl::body Table::_drawTable {} {
global isMac
global g_titleFont
set _droot ".[namespace tail $this]"
if { [winfo exists $_droot] } {
destroy $_droot
}
powToplevel $_droot .dummy
wm geometry $_droot +50+[winfo pointery .]
setFileName $fileName
set _firstRow 1
set _firstCol 1
set _fitsFileLocationCol -1
_setupTable
# Ziqin Apr 01,2004
frame $_droot.table
bind $_droot <Destroy> +[itcl::code $this _closeFrWm %W]
set can $_droot.table.can
set hdr $_droot.table.hdr
canvas $hdr \
-width $_DC(xsize) \
-height $_DC(headroom) -highlightthickness 0
canvas $can \
-width $_DC(xsize) \
-height $_DC(ysize) \
-relief ridge -borderwidth 5
bind $can <Configure> +[itcl::code $this _resizeCan %w %h]
bind $can <Home> [itcl::code $this _jumpTo 0]
bind $can <Up> [itcl::code $this _cellUp]
bind $can <Down> [itcl::code $this _cellDown]
bind $can <Left> [itcl::code $this _cellLeft]
bind $can <Right> [itcl::code $this _cellRight]
bind $can <Prior> [itcl::code $this _pageUp]
bind $can <Next> [itcl::code $this _pageDown]
bind $can <KeyPress> "\
focus $_droot.usrEntry.sel_e; \
event generate $_droot.usrEntry.sel_e <KeyPress> -when now \
-keysym %K -keycode %k"
scrollbar $_droot.table.vscroll -width $_DC(vscrollsize) -orient vertical \
-command [itcl::code $this _setVScroll]
scrollbar $_droot.table.hscroll -width $_DC(hscrollsize) -orient horizontal \
-command [itcl::code $this _setHScroll]
if { $_numRows } {
$_droot.table.vscroll set 0.0 \
[expr double($_showRows)/$_numRows]
} else {
$_droot.table.vscroll set 0.0 1.0
}
if { $_listPreSelectedColNames == "" } {
$_droot.table.hscroll set 0.0 1.0
} else {
$_droot.table.hscroll set 0.0 \
[expr double($_showCols)/[llength $_listPreSelectedColNames]]
}
pack $_droot.table.hdr -side top -fill x -anchor w
pack $_droot.table.vscroll -side right -fill y
pack $_droot.table.hscroll -side bottom -fill x
pack $_droot.table.can -side top -fill both -expand 1
frame $_droot.usrEntry -height $_DC(footroom) \
-relief raised -borderwidth 0
entry $_droot.usrEntry.goto_e -width 10 \
-relief sunken -bd 2 -font g_titleFont
bind $_droot.usrEntry.goto_e <Return> [itcl::code $this _jumpFrEnt]
button $_droot.usrEntry.goto_b -text "Go to:" \
-command [itcl::code $this _jumpFrEnt] -font g_titleFont
label $_droot.usrEntry.sel -text " Edit cell:" -font g_titleFont
entry $_droot.usrEntry.sel_e -width 22 \
-textvariable [itcl::scope _cellVar] -relief sunken -bd 2 -font g_titleFont
bind $_droot.usrEntry.sel_e <Return> [itcl::code $this _editCell]
if { ($_tableType == "Image") || ($_tableType == "Vector Table") } {
checkbutton $_droot.usrEntry.lock -text "Lock to Parent " \
-font g_titleFont \
-variable [itcl::scope _isVScrollLocked1 ] \
-selectcolor $fvPref::checkBBgColor \
-activeforeground black -activebackground $fvPref::globalBgColor \
-command {}
}
pack $_droot.usrEntry.goto_b -side left
pack $_droot.usrEntry.goto_e -side left
pack $_droot.usrEntry.sel -side left
pack $_droot.usrEntry.sel_e -side left
catch { pack $_droot.usrEntry.lock -side right }
pack $_droot.usrEntry -side bottom -fill x
pack $_droot.table -side top -fill both -expand 1
# draw the lines and entries ...
_drawTableFrame
# Bind window to menu events
bind $_droot <<PostMenus>> [itcl::code $this _postMenus]
bind $_droot <<SaveFile>> [itcl::code $this _saveFile]
bind $_droot <<SaveFileAs>> [itcl::code $this _saveAs]
bind $_droot <<Export>> [itcl::code $this _export]
bind $_droot <<ExportAs>> [itcl::code $this _saveASCII]
bind $_droot <<CloseWindow>> [itcl::code $this closeCmd]
bind $_droot <<Copy>> [itcl::code $this _cpyToCB]
bind $_droot <<Paste>> [itcl::code $this _cpyFrCB]
}
itcl::body Table::_setupTable { } {
set lastCol [llength $_listPreSelectedColNames]
if {$_showRows > $_numRows} {
set _showRows $_numRows
}
if {$_showCols > $lastCol} {
set _showCols $lastCol
}
if { $_firstCol > [expr $lastCol -$_showCols+1]} {
set _firstCol [expr $lastCol -$_showCols+1]
}
if { $_firstRow > [expr $_numRows -$_showRows+1]} {
set _firstRow [expr $_numRows -$_showRows+1]
}
# the - $_DC(rightspace)/2 appears to be a hack, so that the table looks prettier
# and not so frayed at the right margin...taking it out will show you what I mean
set _DC(xsize) [expr $_absXPos([expr $_firstCol-1+$_showCols]) \
- $_absXPos([expr $_firstCol-1]) + $_absXPos(0) \
- $_DC(rightspace)/2 ]
if { $_DC(xsize) > [winfo screenwidth .] } {
set _DC(xsize) [expr [winfo screenwidth .] - 20]
}
set _DC(ysize) [expr 2*$_DC(tmar) + $_showRows*($_DC(height)+$_DC(interline))]
_getXYSize $_DC(xsize) $_DC(ysize)
_getLastFirstCol
_updateLast
}
itcl::body Table::_getLastFirstCol {} {
# base on the size of the canvas, find out the beginning of the
# last page of the table.
set tmpWidth [expr $_DC(lmar) + $_DC(width) + $_DC(rightspace)]
for { set i $_dispCols} {$i > 0} {incr i -1} {
set tmpWidth [expr $tmpWidth+$_cellPixWidth([expr $i-1])+$_DC(rightspace) + 10]
if { $tmpWidth > $_DC(xsize) } {
break
}
}
set _lastFirstCol [expr $i +1]
}
itcl::body Table::_buildMenus {} {
#puts "_buildMenus start"
global isMac
global g_titleFont
if { $isMac } {
set _mBar .mbar.table
} else {
set _mBar $_droot.mbar
}
$_droot config -menu $_mBar
if { ![winfo exists $_mBar] } {
_buildNewMenus
}
}
itcl::body Table::_buildNewMenus {} {
#puts "_buildNewMenus start"
global isMac isWin
global g_titleFont
menu $_mBar -font g_titleFont
if { $isMac } {
set evtWndw ""
set cmdkey "Cmd"
$_mBar add cascade -menu $_mBar.apple
$_mBar add cascade -menu $_mBar.file -label File
$_mBar add cascade -menu $_mBar.edit -label Edit
$_mBar add cascade -menu $_mBar.tools -label Tools
$_mBar add cascade -menu .mbar.wind -label Windows
$_mBar add cascade -menu $_mBar.help -label Help
buildAppleStyleMenu $_mBar.apple
} else {
set evtWndw $_droot
set cmdkey "Alt"
$_mBar add cascade -menu $_mBar.file -label File
$_mBar add cascade -menu $_mBar.edit -label Edit
$_mBar add cascade -menu $_mBar.tools -label Tools
$_mBar add cascade -menu $_mBar.help -label Help
}
# FILE
if { $isMac } {
buildFileMenu $_mBar.file
if { ($_tableType == "Binary Table") || ($_tableType == "ASCII Table")} {
$_mBar.file entryconfig "Export" -label "Export HDU..."
}
$_mBar.file entryconfig "ExportAs" -label "Export as Text..." \
-state normal -font g_titleFont
$_mBar.file entryconfig "Save As..." -state normal -font g_titleFont
$_mBar.file entryconfig "Close" -state normal -font g_titleFont
} else {
menu $_mBar.file -tearoff False
$_mBar.file add command -label "Save" -underline 0 \
-command "doMenuEvent <<SaveFile>>" -accelerator "$cmdkey+S" -font g_titleFont
if { ($_tableType == "Binary Table") || ($_tableType == "ASCII Table")} {
$_mBar.file add command -label "Export HDU..." \
-command "doMenuEvent <<Export>>" -font g_titleFont
}
$_mBar.file add command -label "Export as Text..." \
-command "doMenuEvent <<ExportAs>>" -font g_titleFont
$_mBar.file add command -label "Close" \
-command "doMenuEvent <<CloseWindow>>" -accelerator "$cmdkey+W" -font g_titleFont
}
# EDIT
buildEditMenu $_mBar.edit
# TOOLS
menu $_mBar.tools -tearoff False
# HELP
buildHelpMenu $_mBar.help tableDisplay "Table Display"
# Configure the Post Commands
if { $isMac || $isWin } {
# The Mac and Windows post all menus at once, so we only need
# to do the post on the top level
$_mBar configure -postcommand "doMenuEvent <<PostMenus>> $evtWndw"
} else {
# Unix has to post each individual menu
$_mBar.file configure -postcommand \
"doMenuEvent <<PostMenus>> $evtWndw"
$_mBar.edit configure -postcommand \
"doMenuEvent <<PostMenus>> $evtWndw"
$_mBar.tools configure -postcommand \
"doMenuEvent <<PostMenus>> $evtWndw"
}
}
itcl::body Table::_postMenus {} {
#puts "_postMenus start"
if { [$fFile isFileChanged] && ![$fFile isReadOnly] } {
$_mBar.file entryconfigure Save -state normal
} else {
$_mBar.file entryconfigure Save -state disabled
}
set clipType [lindex [fvClipBoard report] 0]
if { ($clipType == "table") && !$isFailedToCopy } {
$_mBar.edit entryconfigure "Paste" -state normal
} else {
$_mBar.edit entryconfigure "Paste" -state disabled
}
if { $_cstartx == "" } {
$_mBar.edit entryconfigure "Copy" -state disabled
} else {
$_mBar.edit entryconfigure "Copy" -state normal
}
}
itcl::body Table::scplotCmd {{xyname_ {}}} {
global g_charPix
set _DC(height) 20
set _DC(width) [expr ($_numRows !=0 )? \
(int(log10($_numRows))+4)*$g_charPix : 100 ]
set _DC(headroom) 80
set _DC(footroom) 40
set _DC(vscrollsize) 15
set _DC(hscrollsize) 15
# space to the right of the data
set _DC(rightspace) 6
# space between lines
set _DC(interline) 0
# top margin
set _DC(tmar) 6
# left margin
set _DC(lmar) 8
set _listPreSelectedColNames $_listColNames
# let the destructor know
set _isDirPlot 1
#
_readInTable
# Ziqin Pan , Feb 18, 2004
# add to support row selection
_initSelRows
#
#
set argc [llength $xyname_]
if { $argc<4 || $argc>6 } {
_plotCmd
} elseif { $argc>5 } {
eval _plotCols $xyname_
} else {
if { $argc==4 } {
set flag 0
set range "-"
set sel 0
foreach {x xe y ye } $xyname_ {}
} elseif { $argc==5} {
set range "-"
set sel 0
foreach {x xe y ye flag} $xyname_ {}
} else {
set sel 0
foreach {x xe y ye flag range} $xyname_ {}
}
_plotCols $x $xe $y $ye $flag $range $sel
}
itcl::delete object $this
}
itcl::body Table::_plotCmd {} {
#puts "_plotCmd start"
set nameList [list RowNumber ElementNumber]
set vecList [list 1 1]
for {set i 0} {$i < $_dispCols} {incr i} {
if { $_columnVecSize($i) > 0 } {
# lappend vecList $_columnVecSize($i)
lappend vecList $_columnDim($i)
lappend nameList [lindex $_listPreSelectedColNames $i]
}
}
if { [winfo exists .pltSel] } {
.pltSel quitCmd
}
set _ftp [FitsPlotSel .pltSel $this $nameList $vecList [itcl::code $this _plotCols]]
wm title .pltSel "Select Plot Columns"
_showselCheck
tkwait window .pltSel
set _ftp 0
}
itcl::body Table::_getDataForAxis { axis_ axisExpression_ whichRows_ } {
if { $axisExpression_ == "RowNumber" } {
set axisExpression_ "#ROW"
set dataType 41
set nelem [range count $whichRows_ $_numRows]
set dim 1
} else {
if { [catch {set xinfo [$fFile getExprInfo $axisExpression_]} err] } {
error "Cannot plot expression for $axis_.\n\n$err"
}
set dataType [lindex $xinfo 0]
set nelem [lindex $xinfo 1]
set dim [lindex $xinfo 2]
if { $dataType!=41 && $dataType!=82 } {
error "Cannot plot expression type for $axis_.\
Expression must evaluate to INT or REAL"
}
if { $nelem == -1 } {
# Scalar constants could be applied to either nRows or nElems
# so just return a solitary value and expand later as needed
set whichRows_ 1
} elseif { $nelem < -1 } {
# Treat vector constants as a regular vector column
set nelem [expr -$nelem]
}
}
set dataInfoForPOW [$fFile loadExpr $axisExpression_ NULL $whichRows_]
set dataPtr [lindex $dataInfoForPOW 0]
set dataType [lindex $dataInfoForPOW 1]
set numElements [lindex $dataInfoForPOW 2]
return [list $dataPtr $dataType $numElements $nelem $dim]
}
itcl::body Table::callHistogramDirectly { extNum_ fillFlag_ } {
global g_histoParam
set nameList $_listPreSelectedColNames
set tmpName [namespace tail $this]
# set ft [FitsHistoParam .his_$tmpName $fFile $nameList $this]
set _fth [FitsHistoParam .his_$tmpName $fFile $nameList $this]
if { $fillFlag_ == "true" } {
# $ft insertDefaultValue
$_fth insertDefaultValue
wm title .his_$tmpName "fv: Histogram"
tkwait window .his_$tmpName
if { $g_histoParam == "" } return
# _makeHistogram $extNum_
} else {
wm title .his_$tmpName "fv: Histogram"
tkwait window .his_$tmpName
}
set _fth 0
# Ziqin Pan
# itcl::delete object $this
closeCmd
#
}
itcl::body Table::_histoCmd {} {
global g_histoParam
set g_histoParam ""
set nameList $_listPreSelectedColNames
set tmpName [namespace tail $this]
set _fth [FitsHistoParam .his_$tmpName $fFile $nameList $this]
wm title .his_$tmpName "fv: Histogram"
_showselCheck
tkwait window .his_$tmpName
set _fth 0
if { $g_histoParam == "" } return
# _makeHistogram
}
itcl::body Table::_setOpCancel {} {
set _opCancel true
destroy .di
}
itcl::body Table::_setOverWriteFlag {} {
set _opCancel false
set _overWriteImage $_overWriteImageValue
destroy .di
}
itcl::body Table::_determineOverWriteFlag {} {
if [winfo exists .di] {
destroy .di
}
if [winfo exists .pow.pow] {
powToplevel .di .dummy
wm title .di "fv: Ask to Replace Selected Image"
label .di.label -text "Replace current selected image?" -font g_titleFont
label .di.empty -text " " -font g_titleFont
radiobutton .di.yes -variable [itcl::scope _overWriteImageValue] -value "yes" \
-font g_titleFont -text "Yes"
radiobutton .di.no -variable [itcl::scope _overWriteImageValue] -value "no" \
-font g_titleFont -text "No"
checkbutton .di.check -text "Don't ask anymore on remaining \nsession of current FITS file." \
-onvalue true -offvalue false \
-justify left \
-font g_titleFont -variable [itcl::scope _neverAskFlagValue]
button .di.ok -text OK -command [itcl::code $this _setOverWriteFlag]
button .di.cancel -text Cancel -command [itcl::code $this _setOpCancel]
grid .di.label -row 0 -column 0 -pady 5 -padx 5 -sticky news -columnspan 5
grid .di.yes -row 1 -column 1 -padx 1 -pady 1 -sticky news
grid .di.no -row 1 -column 3 -padx 1 -pady 1 -sticky news
grid .di.empty -row 2 -column 0 -padx 1 -pady 1 -sticky news -columnspan 5
grid .di.check -row 3 -column 0 -padx 1 -pady 1 -sticky news -columnspan 5
grid .di.ok -row 4 -column 1 -padx 1 -pady 1 -sticky nes
grid .di.cancel -row 4 -column 3 -padx 1 -pady 1 -sticky nws
if { $_overWriteImageValue == "yes" } {
.di.yes select
} else {
.di.no select
}
tkwait window .di
}
}
itcl::body Table::_ds9MakeImage { fh colIdx slice xSize ySize } {
global g_backupDir
set fCol_ $colIdx
set filemode 2
set tmpfile ${g_backupDir}/ds9Temp.fit
if [file exists $tmpfile] {
file delete -force $tmpfile
}
if { [catch {set newfits [fits open $tmpfile $filemode]} err] } {
error $err
return
}
# command: fitsFile put ihd -p bitpix naxes axis_list
# $newfits put ihd -p 32 2 {$xSize $ySize}
set key [$fFile getKeyword TFORM[expr $colIdx + 1]]
set datavalue [string trim [lindex [lindex $key 0] 1] {' ()}]
scan $datavalue "%d%s" value dataType
switch $dataType {
"L" {
set dataForm 8
}
"X" {
set dataForm 8
}
"I" {
set dataForm 16
}
"J" {
set dataForm 32
}
"A" {
set dataForm 8
}
"E" {
set dataForm -32
}
"D" {
set dataForm -64
}
"B" {
set dataForm 8
}
"C" {
set dataForm -32
}
"M" {
set dataForm -64
}
"P" {
set dataForm -64
}
}
#puts "value: $value"
$newfits put ihd -p $dataForm 2 {$xSize $ySize}
$newfits put keyword "NAXIS1 $xSize"
$newfits put keyword "NAXIS2 $ySize"
set datatList {}
for {set i 1} {$i <= [expr $xSize * $ySize]} {incr i} {
lappend dataList [$fh get vtable -noformat $_tType($colIdx) $i $slice]
}
catch { $newfits put image 1 1 $dataList } err
$newfits close
set err "none"
catch {exec xpaaccess ds9} result
if { [string range $result 0 1] == "no" } {
# start DS9 if DS9 isn't there
if { [catch {exec ds9 &} ds9pid] } {
file delete $tmpfile
if { [tk_dialog .saoError "DS9 startup error.. Cannot start DS9!\nUse POW instead?" \
question 0 Yes No] == 0 } {
close $fFile
return NO_YET
}
close $fFile
return DONE
}
# wait till ds9 is up
set flag 1
set nSecs 0
while { $flag } {
after 1000
incr nSecs
catch {exec xpaaccess ds9} result
if { [string range $result 0 2] == "yes" } {
set flag 0
} else {
if { $nSecs > 10 } {
file delete $tmpfile
if { [tk_dialog .saoError "DS9 startup error.. Cannot start ds9!\nUse POW instead?" \
question 0 Yes No] == 0 } {
close $fFile
return NO_YET
}
close $fFile
return DONE
}
}
}
}
set displayName [format "%s\(%s\)" [file tail $fileName] $slice]
exec xpaset ds9 fits $displayName < $tmpfile
file delete $tmpfile
return DONE
}
itcl::body Table::_determineRealSlice { slice } {
if ![info exists sortRowResultList] {
return $slice
}
return [lindex $sortRowResultList [expr $slice + - 1]]
}
itcl::body Table::_displaySlice { colIdx slice } {
global g_titleFont
global g_backupDir
global xFactor yFactor
global currgn powFirstTimeThroughFlag powPlotParam currimg
global xCount yCount
global powFitsHeader powFitsHeaderCnt powPlotParam
global powWCSList powWCSLabel powWCSName powWCS
global useWCSInfo
if { [string first "ftp" $fileName] >= 0 } {
set fileName [format "%s/%s/%s" $::env(HOME) $g_backupDir [file tail $fileName]]
}
set slice [expr $_firstRow + $slice]
set slice [_determineRealSlice $slice]
set xSize [lindex $_arrayDim($colIdx) 0]
set ySize [lindex $_arrayDim($colIdx) 1]
set fh [fits open $fileName 0]
$fh move +[expr ${_extNum} - 1]
if { $fvPref::imgDisplayer == "DS9" } {
# display is for DS9
set flag "NOT_YET"
set flag [_ds9MakeImage $fh $colIdx $slice $xSize $ySize ]
if { $flag == "DONE" } {
return
}
}
if { [winfo exist .pow.pow]!=1 } {
powInit .dummy
}
regsub -all { } [urlTail $fileName] _ cleanFileName
set graphHandle [format "%s\(%s_%s)_%s" ${cleanFileName} $_tType($colIdx) $slice $_graphIDhighest]
set oldgn ""
if { [info exists currimg] && $currimg!="NULL" && $currimg!="" } {
if { $_neverAskFlagValue == "false" } {
_determineOverWriteFlag
if { $_opCancel == "true" } return
}
# the graph is not already on .pow.pow, if _overWriteImage is yes, then delete the previous
# selected image.
if { $_overWriteImage == "yes" } {
if { $currgn != "powDef" } {
set oldgn $currgn
set xo $powPlotParam(xo,$currgn)
set yo $powPlotParam(yo,$currgn)
}
set currgn ""
}
}
# set graphHandle ${cleanFileName}_[expr $currentHDU-1]_$_graphIDhighest
# call fits_copy_cell2image to translate the keyword and wcs
set result [$fFile translateKeyWords $_tType($colIdx) $slice]
# fitsObj load arrayRow <column name> <row number> <number element> <null string> <first element>
set alist [$fh load arrayRow $_tType($colIdx) $slice [expr $xSize * $ySize] NULL 1]
eval powCreateData $graphHandle $alist
set wcsinfo [lindex $result 2]
set powWCS($graphHandle) $wcsinfo
set powWCS(${graphHandle}scope) $powWCS($graphHandle)
set powWCS(imgobj_$graphHandle) $powWCS($graphHandle)
set useWCSInfo(${graphHandle}scope) $fvPref::ifWCSInfo
set useWCSInfo($graphHandle) $fvPref::ifWCSInfo
#set result [$fFile getHeader2String]
#set cntList($graphHandle) [$fFile getHeaderKeyWord [lindex $result 0] $graphHandle]
set cntList($graphHandle) [$fFile getHeaderKeyWord [lindex $result 0] $graphHandle]
set powFitsHeaderCnt($graphHandle) [lindex $cntList($graphHandle) 1]
if { [lindex $cntList($graphHandle) 0] > 0 } {
set powFitsHeader($graphHandle) [lindex $result 0]
set powWCSInfo($graphHandle,DEFAULT) $powWCS($graphHandle)
} else {
set powFitsHeader($graphHandle) [$fFile assembleWcsHeader $graphHandle NOWCS]
}
set x_label "X"
set y_label "Y"
if { $fvPref::ifWCSInfo } {
set tmp [string trim [lindex [lindex $wcsinfo 3] 0]]
if { $tmp != "" } {
set x_label $tmp
}
set tmp [string trim [lindex [lindex $wcsinfo 3] 1]]
if { $tmp != "" } {
set y_label $tmp
}
#if { $x_unit=="pixels" } {set x_unit NULL}
#if { $y_unit=="pixels" } {set y_unit NULL}
} else {
#set powWCS($imgIndex) {{0.0 0.0} {0.0 0.0} {1.0 -0.0 0.0 1.0} {{} {}} {{} {}}}
}
#puts "powWCS($graphHandle): $powWCS($graphHandle)"
#puts "powFitsHeader($graphHandle): $powFitsHeader($graphHandle)"
set powFitsHeader(imgobj_$graphHandle) $powFitsHeader($graphHandle)
set powFitsHeaderCnt(imgobj_$graphHandle) $powFitsHeaderCnt($graphHandle)
set useWCSInfo(imgobj_$graphHandle) $useWCSInfo($graphHandle)
set powWCSName(imgobj_$graphHandle) 0
powCreateImage imgobj_$graphHandle $graphHandle 0 0 $xSize $ySize 1 1 1 1 $x_label $y_label value
set powWCSList(imgobj_$graphHandle) {}
lappend powWCSList(imgobj_$graphHandle) 1
lappend powWCSList(imgobj_$graphHandle) {}
set powWCSName($graphHandle) 0
set powWCSList($graphHandle) $powWCSList(imgobj_$graphHandle)
set powWCSList(${graphHandle}scope) $powWCSList(imgobj_$graphHandle)
set powPlotParam(graphType,$graphHandle) [string tolower [lindex [$fh info hdutype] 0]]
set powPlotParam(graphType,${graphHandle}scope) $powPlotParam(graphType,$graphHandle)
set powPlotParam(zoomed,$graphHandle) 0
set powPlotParam(zoomed,${graphHandle}scope) 0
set xCount($graphHandle) 0
set yCount($graphHandle) 0
set xCount(${graphHandle}scope) 0
set yCount(${graphHandle}scope) 0
set powWCSLabel(xlabel,imgobj_$graphHandle,DEFAULT) $x_label
set powWCSLabel(ylabel,imgobj_$graphHandle,DEFAULT) $y_label
set powWCSLabel(xunit,imgobj_$graphHandle,DEFAULT) "pixels"
set powWCSLabel(yunit,imgobj_$graphHandle,DEFAULT) "pixels"
set powWCSLabel(xlabel,$graphHandle,DEFAULT) $x_label
set powWCSLabel(ylabel,$graphHandle,DEFAULT) $y_label
set powWCSLabel(xunit,$graphHandle,DEFAULT) "pixels"
set powWCSLabel(yunit,$graphHandle,DEFAULT) "pixels"
set x_unit "pixels"
set y_unit "pixels"
set z_label "counts"
if { ![catch {set tmp [_getKeywordValue CTYPE1 $powFitsHeader($graphHandle)]}] } {
if { $tmp != "" } {
set x_label $tmp
}
}
if { ![catch {set tmp [_getKeywordValue CTYPE2 $powFitsHeader($graphHandle)]}] } {
if { $tmp != "" } {
set y_label $tmp
}
}
if { ![catch {set tmp [_getKeywordValue CUNIT1 $powFitsHeader($graphHandle)]}] } {
if { $tmp != "" } {
set x_unit $tmp
}
}
if { ![catch {set tmp [_getKeywordValue CUNIT2 $powFitsHeader($graphHandle)]}] } {
if { $tmp != "" } {
set y_unit $tmp
}
}
if { ![catch {set tmp [_getKeywordValue BUNIT $powFitsHeader($graphHandle)]}] } {
if { $tmp != "" } {
set z_label $tmp
}
}
powCreateGraph $graphHandle NULL imgobj_$graphHandle $x_unit $y_unit $x_label $y_label \
[lindex $fvPref::graphDispSize 0] [lindex $fvPref::graphDispSize 0]
if [info exists xo] {
powMoveGraphTo $graphHandle $xo $yo .pow.pow
foreach el [list xTop yTop xBot yBot xo yo graphWidth graphHeight xmagstep ymagstep] {
unset powPlotParam($el,$oldgn)
}
powDeleteGraph $oldgn NOPROMPT
powDeleteImage $oldgn $oldgn
# set _graphIDhighest [expr $_graphIDhighest - 1]
powReconfigureToplevel 1
}
if { [info exists xFactor] && [info exists yFactor] } {
powStretchGraph $graphHandle $xFactor $yFactor
}
incr _graphIDhighest
catch {$fh close} err
set powPlotParam(zoomed,$currimg) 0
}
itcl::body Table::_getKeywordValue { keyword header } {
set k 0
set tokenStr ""
for {set i 0} {$i < [string length $header]} {incr i 80} {
set currentStr [string range $header $i [expr $i + 79]]
if { [string range $currentStr 0 [expr [string length $keyword] - 1]] == $keyword } {
set tokenStr $currentStr
break
}
incr k
}
set valueStr [lindex [split [string range $tokenStr 10 end] "/"] 0]
regsub -all {'} $valueStr {} returnValue
return [string trim $returnValue]
}
itcl::body Table::_displayMovie { colIdx slice } {
global g_titleFont
set slice [expr $_firstRow + $slice]
set slice [_determineRealSlice $slice]
set xSize [lindex $_arrayDim($colIdx) 0]
set ySize [lindex $_arrayDim($colIdx) 1]
set _istart 1
set _iend [lindex $_arrayDim($colIdx) 2]
# image selection
if { [winfo exist .fv_imgsel] == 1 } {
destroy .fv_imgsel
}
powToplevel .fv_imgsel .dummy
wm title .fv_imgsel "fv: Image Selection"
label .fv_imgsel.label -text "The image has $_iend slices" \
-relief ridge -borderwidth 4 -font g_titleFont
label .fv_imgsel.sl -width 5 -text "Start" -font g_titleFont
entry .fv_imgsel.se -width 10 -textvariable [itcl::scope _istart] -font g_titleFont
label .fv_imgsel.el -width 5 -text "End" -font g_titleFont
entry .fv_imgsel.ee -width 10 -textvariable [itcl::scope _iend] -font g_titleFont
button .fv_imgsel.anim -text "Animate" \
-command "[itcl::code $this _createMovie $colIdx $slice $xSize $ySize]
destroy .fv_imgsel" -font g_titleFont
button .fv_imgsel.cancel -text "Cancel" \
-command "destroy .fv_imgsel" -font g_titleFont
button .fv_imgsel.help -text "Help" \
-command "hhelp 3D-ImageDisplay" -font g_titleFont
grid .fv_imgsel.label -column 0 -row 0 -columnspan 4 -sticky "snew"
grid .fv_imgsel.sl -column 0 -row 1
grid .fv_imgsel.se -column 1 -row 1
grid .fv_imgsel.el -column 2 -row 1
grid .fv_imgsel.ee -column 3 -row 1
grid .fv_imgsel.anim -column 0 -row 2
grid .fv_imgsel.cancel -column 1 -row 2
grid .fv_imgsel.help -column 3 -row 2
}
itcl::body Table::_createMovie { colIdx slice xSize ySize } {
global powWCS powFitsHeader powFitsHeaderCnt powPlotParam
global xCount yCount
global powWCSName powWCSTranslation powWCSLabel powWCSList
global useWCSInfo
global g_backupDir
if { [string first "ftp" $fileName] >= 0 } {
set fileName [format "%s/%s/%s" $::env(HOME) $g_backupDir [file tail $fileName]]
}
regsub -all { } [urlTail $fileName] _ cleanFileName
# set imgHandle ${cleanFileName}_[expr $currentHDU-1]_$_graphIDhighest
set imgHandle ${cleanFileName}_[expr $currentHDU-1]
if { [winfo exist .pow.pow]!=1 } {
powInit .dummy
}
# open the fits file
set fh [fits open $fileName 0]
# move down on HDU to get to the really data
$fh move +[expr ${_extNum} - 1]
set x_label "X"
set y_label "Y"
set x_unit "pixel"
set y_unit "pixel"
if { $fvPref::ifWCSInfo } {
set result [$fFile getHeader2String]
set cntList($imgHandle) [$fFile getHeaderKeyWord [lindex $result 0] $imgHandle]
set powFitsHeaderCnt($imgHandle) [lindex $cntList($imgHandle) 1]
if { [lindex $cntList($imgHandle) 0] > 0 } {
#set powFitsHeader($imgHandle) [$fFile assembleWcsHeader $imgHandle]
set powFitsHeader($imgHandle) [lindex $result 0]
set powWCSInfo($imgHandle,DEFAULT) $powWCS($imgHandle)
set wcsinfo $powWCS($imgHandle)
set x_label [lindex [lindex $wcsinfo 3] 0]
set y_label [lindex [lindex $wcsinfo 3] 1]
if { $x_unit=="pixels" } {set x_unit NULL}
if { $y_unit=="pixels" } {set y_unit NULL}
} else {
set powFitsHeader($imgHandle) [$fFile assembleWcsHeader $imgHandle NOWCS]
set powWCS($imgHandle) [$fFile getWcs]
}
} else {
set powWCS($imgHandle) {{0.0 0.0} {0.0 0.0} {1.0 -0.0 0.0 1.0} {{} {}} {{} {}}}
set powFitsHeader($imgHandle) ""
set powFitsHeaderCnt($imgHandle) 0
}
set powWCSList($imgHandle) {}
set powWCSList(${imgHandle}scope) {}
set imgList {}
for {set i [expr $_istart - 1]} {$i < $_iend} {incr i} {
# fitsObj load arrayRow <column name> <row number> <number element> <null string> <first element>
set alist [$fh load arrayRow $_tType($colIdx) $slice [expr $xSize * $ySize] NULL [expr $i * $xSize * $ySize + 1]]
eval powCreateData ${imgHandle}_$i $alist
if [info exists powWCS(${imgHandle}_$i)] {
catch { unset powWCS(${imgHandle}_$i) }
}
set powFitsHeader(${imgHandle}_$i) $powFitsHeader($imgHandle)
set powFitsHeaderCnt(${imgHandle}_$i) $powFitsHeaderCnt($imgHandle)
catch { set powWCS(${imgHandle}_$i) $powWCS($imgHandle) }
set powPlotParam(graphType,${imgHandle}_$i) \
[string tolower [lindex [$fFile getTableInfo hdutype] 0]]
set powPlotParam(graphType,${imgHandle}_${i}scope) \
$powPlotParam(graphType,${imgHandle}_${i})
set powPlotParam(zoomed,${imgHandle}_${i}) 0
set powPlotParam(zoomed,${imgHandle}_${i}scope) 0
set xCount(${imgHandle}_$i) 0
set yCount(${imgHandle}_$i) 0
set xCount(${imgHandle}_${i}scope) 0
set yCount(${imgHandle}_${i}scope) 0
set powWCSName(${imgHandle}_$i) 0
set powWCSName(${imgHandle}_${i}scope) 0
set powWCSTranslation 0
catch {
powCreateImage ${imgHandle}_$i ${imgHandle}_$i 0 0 $xSize $ySize 1 1 1 1 pixels pixels value
} err
if [info exists powWCSList(${imgHandle}_${i})] {
foreach name [lindex $powWCSList(${imgHandle}_$i) 1] {
$fFile assembleWcsLabel ${imgHandle}_$i $name
}
} else {
set powWCSList(${imgHandle}_${i}) {}
lappend powWCSList(${imgHandle}_${i}) 1
lappend powWCSList(${imgHandle}_${i}) {}
}
set powWCSList(${imgHandle}_${i}scope) $powWCSList(${imgHandle}_${i})
lappend imgList ${imgHandle}_$i
set powWCSLabel(xlabel,${imgHandle}_$i,DEFAULT) $x_label
set powWCSLabel(ylabel,${imgHandle}_$i,DEFAULT) $y_label
set powWCSLabel(xunit,${imgHandle}_$i,DEFAULT) $x_unit
set powWCSLabel(yunit,${imgHandle}_$i,DEFAULT) $y_unit
lappend imgList ${imgHandle}_$i
}
set powPlotParam(graphType,$imgHandle) [string tolower [lindex [$fh info hdutype] 0]]
set powPlotParam(graphType,${imgHandle}scope) $powPlotParam(graphType,$imgHandle)
set powPlotParam(zoomed,$imgHandle) 0
set powPlotParam(zoomed,${imgHandle}scope) 0
set xCount($imgHandle) 0
set yCount($imgHandle) 0
set xCount(${imgHandle}scope) 0
set yCount(${imgHandle}scope) 0
powCreateGraph $imgHandle NULL $imgList $x_unit $y_unit \
$x_label $y_label [lindex $fvPref::graphDispSize 0] \
[lindex $fvPref::graphDispSize 1]
if { [info exists xFactor] && [info exists yFactor] } {
powStretchGraph $imgHandle $xFactor $yFactor
}
catch {$fh close} err
# incr _graphIDhighest
powMovie
after 1 powPlayMovie
}
itcl::body Table::_makeHistogram { {extNum_ {}} } {
global g_histoParam
global g_histoFileID
global g_backupDir
global g_fitsFileMode
set oldMode $g_fitsFileMode
# Set Read-Only flag
set g_fitsFileMode 1
set fileName ""
set fileName [file join $g_backupDir histo.tmp$g_histoFileID]
if ![file exists $fileName] {
# eval $fFile makeHistogram $g_histoParam
}
set foundFlag false
set fftmp [openFitsFile $fileName]
incr g_histoFileID
$fftmp plotHisto
$fftmp changeFile
if { $extNum_ != "" } {
$fftmp plotData $extNum_
}
set g_fitsFileMode $oldMode
}
# called by FitsPlotSel::_plotCmd
# any of the input axes (x, xe, y, ye) can also be expressions
# not just a column name
#
itcl::body Table::_plotCols { xColumn_ xeColumn_ yColumn_ yeColumn_ {inCurrGraph_ 0} {whichRows_ "-"} {plotSelOnly_ 0}} {
global powWCS powFitsHeader powFitsHeaderCnt
global xFactor yFactor powPlotParam currimg
global powPlotColumnDataName
global xCount yCount
global powWCSName powWCSTranslation powWCSLabel powWCSList
global useWCSInfo
set xColumn $xColumn_
set yColumn $yColumn_
set cbCurrgn 0
if { $_ftp != 0 } {
set cbCurrgn [$_ftp returnAddMyCurve]
}
if { $whichRows_ == "" || $whichRows_ =="-" } {
set whichRows_ "1-$_numRows"
}
if { $plotSelOnly_ == 1 } {
set selrange ""
set tmplist [split $whichRows_ ","]
set numlist [llength $tmplist]
for { set k 0 } {$k <$numlist } {incr k} {
set start_end [lindex $tmplist $k]
if { $selrange =="" } {
append selrange [_parseToRowRange $start_end]
} else {
append selrange "," [_parseToRowRange $start_end]
}
}
set whichRows_ $selrange
}
set inputXcolumn $xColumn_
set inputYcolumn $yColumn_
if { $fvPref::imgDisplayer == "DS9" } {
# display is for DS9
# if { $xeColumn_ != "" || $yeColumn_ != "" } {
# tk_messageBox -icon error -type ok \
# -message "ds9 can't display either X error and Y error, try POW instead."
# return
# }
set xColumn_ [string toupper $xColumn_ ]
set yColumn_ [string toupper $yColumn_ ]
set colIdx -1
foreach name $_listPreSelectedColNames {
if { [string first $name $xColumn_] >= 0 } {
set colIdx [lsearch $_listPreSelectedColNames $name ]
break
}
}
if { $colIdx < 0 } {
foreach name $_listPreSelectedColNames {
if { [string first $name $yColumn_] >= 0 } {
set colIdx [lsearch $_listPreSelectedColNames $name ]
break
}
}
}
if { $colIdx < 0 } {
# both xcolumn and ycoloumn are not in the _listPreSelectedColNames
tk_messageBox -icon error -type ok \
-message "Please select one of the following:\n\n$_listPreSelectedColNames"
return
}
#puts $whichRows_
set flag "NOT_YET"
# set flag [_ds9MakePlot NONE 1 $_numRows $xColumn_ $yColumn_ $xeColumn_ $yeColumn_]
set flag [_ds9MakePlot1 NONE $whichRows_ $xColumn_ $yColumn_ $xeColumn_ $yeColumn_ $inCurrGraph_]
if { $flag == "DONE" } return
}
if { $whichRows_ == "-" } {
set nRows $_numRows
} else {
set nRows [range count $whichRows_ $_numRows]
}
regsub -all { } [urlTail $fileName] _ cleanFileName
set graphID table_${cleanFileName}_$_graphIDhighest
#
# Analyze the expressions
#
foreach axis [list x y xe ye] {
set axisExpression [subst \$${axis}Column_]
#puts "axisExpression: $axisExpression"
# for example: set exprData(x,expr) $xColumn_
set exprData($axis,expr) $axisExpression
if { $axisExpression == "" || $axisExpression == "NULL" } {
# No expression supplied. OK for errorbars, not allowed for x/y
if { $axis == "x" || $axis == "y" } {
error "[string toupper $axis] axis is empty"
} else {
# empty errorbar
set exprData($axis,nelem) 0
set exprData($axis,name1) "NULL"
}
} elseif { $axisExpression == "ElementNumber" } {
# Have to delay data creation until we know how big
# the other axes are
set exprData($axis,nelem) 1
set exprData($axis,name1) "NULL"
} else {
# nelem value will be -1 for scalar constants
set eData [_getDataForAxis $axis $axisExpression $whichRows_]
foreach p [list ptr type len nelem dim] v $eData {
set exprData($axis,$p) $v
set $p $v
}
}
}
#
# Create the vectors
#
set nelem [getmax $exprData(x,nelem) $exprData(y,nelem) \
$exprData(xe,nelem) $exprData(ye,nelem)]
if { $nelem == 1 } {
# All parameters are scalars
set nelem $nRows
} elseif { $nelem < 1 } {
# All parameters are constants or blank, plot just solitary point
set nelem 1
}
foreach axis [list x y xe ye] {
if { $exprData($axis,expr) == "ElementNumber" } {
set exprData($axis,cnt) 1
set exprData($axis,name1) ${axis}1_v_$graphID
set exprData($axis,len) $nelem
powCreateVectorEN $exprData($axis,name1) ElementNumber_$graphID \
$nelem 1 1 NULL
set powPlotColumnDataNameTmp 1_v_$graphID
} elseif { $exprData($axis,nelem) == -1 } {
set val [ptr2lst $exprData($axis,ptr) $exprData($axis,type) 1]
set exprData($axis,cnt) 1
set exprData($axis,name1) ${axis}1_v_$graphID
set exprData($axis,len) $nelem
powCreateVectorEN $exprData($axis,name1) ${axis}_$graphID \
$nelem $val 0 NULL
fits free $exprData($axis,ptr)
set powPlotColumnDataNameTmp 1_v_$graphID
} elseif { $exprData($axis,nelem) != 0 } {
# Test for vector-length compatibility amongst axes
#puts "exprData($axis,len): $exprData($axis,len)"
if { $exprData($axis,nelem) != $nelem && \
($exprData($axis,len) != $nelem || \
$exprData($axis,nelem) != 1) } {
error "[string toupper $axis] axis data length is\
incompatible with other axes"
}
powCreateData ${axis}_$graphID $exprData($axis,ptr) \
$exprData($axis,type) $exprData($axis,len) -1
set powPlotColumnDataNameTmp _$graphID
set cnt 0
set offset 0
while { $offset < $exprData($axis,len) } {
incr cnt
set exprData($axis,name$cnt) ${axis}${cnt}_v_$graphID
powCreateVector $exprData($axis,name$cnt) ${axis}_$graphID \
$offset $nelem 1
incr offset $nelem
}
set exprData($axis,cnt) $cnt
} else {
set exprData($axis,cnt) 1
}
}
# get the x and y units
set xUnit NULL
set yUnit NULL
if { $_tableType != "Vector Table"} {
for {set i 0} {$i < $_dispCols} {incr i} {
if { $_columnName($i) == $xColumn_} {
set xUnit $_columnUnit($i)
if {$xUnit == ""} {set xUnit NULL}
}
if { $_columnName($i) == $yColumn_} {
set yUnit $_columnUnit($i)
if {$yUnit == ""} {set yUnit NULL}
}
}
}
if { [string range $yColumn_ 0 0] == "\$" } {
set yColumn_ [string range $yColumn_ 1 [expr [string length $yColumn_] - 2]]
}
if { [string range $xColumn_ 0 0] == "\$" } {
set xColumn_ [string range $xColumn_ 1 [expr [string length $xColumn_] - 2]]
}
set gColumnName $yColumn_
set gWhichRows $whichRows_
set lWhichRows [split $gWhichRows ","]
if { [llength $lWhichRows] > 1 } {
set gWhichRows ""
append gWhichRows [lindex $lWhichRows 0]
# append gWhichRows ","
# append gWhichRows [lindex $lWhichRows 1]
append gWhichRows "..."
}
if { $whichRows_ == "" || $whichRows_ == "-" } {
set graphHandle ${cleanFileName}_[expr $currentHDU-1]_$_graphIDhighest
} else {
foreach name $_listPreSelectedColNames {
if { [string first $name $gColumnName] == 0 } {
set gColumnName $name
break
}
}
set graphHandle [format "%s\(%s_%s)_%s" ${cleanFileName} $gColumnName $gWhichRows $_graphIDhighest]
}
regsub -all { } $graphHandle "" graphHandle
set oldplot ""
if { (![info exists currimg] || $currimg=="NULL" || $currimg=="") && $cbCurrgn == 0 } {
if { $_neverAskFlagValue == "false" } {
_determineOverWriteFlag
if { $_opCancel == "true" } return
}
# the graph is not already on .pow.pow, if _overWriteImage is yes, then delete the previous
# selected image.
if { $_overWriteImage == "yes" } {
if { [powGetCurrentGraph] != "powDef" } {
set currplot [powGetCurrentGraph]
set oldplot $currplot
set xo $powPlotParam(xo,$currplot)
set yo $powPlotParam(yo,$currplot)
}
}
}
if { [winfo exist .pow.pow]!=1 } {
powInit .dummy
}
set powWCSLabel(xlabel,$graphHandle,DEFAULT) $xColumn_
set powWCSLabel(ylabel,$graphHandle,DEFAULT) $yColumn_
set powWCSLabel(xunit,$graphHandle,DEFAULT) $xUnit
set powWCSLabel(yunit,$graphHandle,DEFAULT) $yUnit
# get the wcs info if it exists
set useWCSInfo(${graphHandle}scope) $fvPref::ifWCSInfo
set useWCSInfo($graphHandle) $fvPref::ifWCSInfo
if { $_tableType != "Vector Table" && $fvPref::ifWCSInfo } {
# Get the WCS info (if needed) and pass them to pow
set RAColNum [lsearch $_listColNames $xColumn_]
set DecColNum [lsearch $_listColNames $yColumn_]
if { ($RAColNum != -1) && ($DecColNum != -1) } {
incr RAColNum
incr DecColNum
# for now, wcsinfo at plot is set to none
set wcsinfo [$fFile getWcs {} $RAColNum $DecColNum]
if { [lindex $wcsinfo 4] != "none" } {
set testCnt 0
foreach item [lindex $wcsinfo 4] {
if { [llength $item] == 0 } {
incr testCnt
}
}
if { $testCnt != [llength [lindex $wcsinfo 4]] } {
set xColumn_ [lindex [lindex $wcsinfo 3] 0]
set yColumn_ [lindex [lindex $wcsinfo 3] 1]
set xUnit "NULL"
set yUnit "NULL"
set powWCSLabel(xlabel,$graphHandle,DEFAULT) $xColumn_
set powWCSLabel(ylabel,$graphHandle,DEFAULT) $yColumn_
set powWCSLabel(xunit,$graphHandle,DEFAULT) $xUnit
set powWCSLabel(yunit,$graphHandle,DEFAULT) $yUnit
}
}
}
}
foreach axis [list x y xe ye] {
set ${axis}i 1
set looping($axis) 1
}
set curves ""
set cnt 0
set powWCSName($graphHandle) 0
while { $looping(x) || $looping(y) || $looping(xe) || $looping(ye) } {
incr cnt
set curveName c${cnt}_$graphHandle
set powWCSName($curveName) 0
set powWCSName(${curveName}scope) 0
set useWCSInfo($curveName) $fvPref::ifWCSInfo
set useWCSInfo(${curveName}scope) $fvPref::ifWCSInfo
if { [info exists wcsinfo] && $wcsinfo!="" } {
set result [$fFile getDummyHeader2String {} $RAColNum $DecColNum]
set powFitsHeader($curveName) [lindex $result 0]
set powWCS($curveName) [lindex $result 2]
set powWCSInfo($curveName,DEFAULT) $powWCS($curveName)
set cntList($curveName) [$fFile getHeaderKeyWord [lindex $result 0] $curveName]
set powFitsHeaderCnt($curveName) [lindex $cntList($curveName) 1]
set wcsinfo $powWCS($curveName)
} else {
set useWCSInfo($curveName) 0
set useWCSInfo(${curveName}scope) 0
set powWCS($curveName) {{0.0 0.0} {0.0 0.0} {1.0 -0.0 0.0 1.0} {{} {}} {{} {}}}
set powFitsHeader($curveName) ""
set powFitsHeaderCnt($curveName) 0
}
set powPlotParam(wcsName,$curveName) "WCS"
set powPlotParam(graphType,$curveName) [string tolower [lindex [$fFile getTableInfo hdutype] 0]]
set powPlotParam(zoomed,$curveName) 0
set powPlotColumnDataName($curveName) $powPlotColumnDataNameTmp
set xCount($curveName) 0
set yCount($curveName) 0
set powPlotParam(wcsName,$curveName) "WCS"
powCreateCurve $curveName $exprData(x,name$xi) $exprData(xe,name$xei) \
$exprData(y,name$yi) $exprData(ye,name$yei)
if [info exists powWCSList($curveName)] {
foreach name [lindex $powWCSList($curveName) 1] {
$fFile assembleWcsLabel $curveName $name
}
} else {
set powWCSList($curveName) {}
lappend powWCSList($curveName) 1
lappend powWCSList($curveName) {}
}
set powWCSList(${curveName}scope) $powWCSList(${curveName})
lappend curves $curveName
foreach axis [list x y xe ye] {
incr ${axis}i
if { [subst \$${axis}i] > $exprData($axis,cnt) } {
set ${axis}i 1
set looping($axis) 0
}
}
}
set realGraphHandle $graphHandle
# wcslist can be obtained from any one slice
if [info exists powWCSList($curveName)] {
set powWCSList($graphHandle) $powWCSList($curveName)
set powWCSList(${graphHandle}scope) $powWCSList($curveName)
foreach name [lindex $powWCSList($graphHandle) 1] {
$fFile assembleWcsLabel $graphHandle $name
}
} else {
set powWCSList($graphHandle) {}
lappend powWCSList($graphHandle) 1
lappend powWCSList($graphHandle) {}
}
set powWCSList(${graphHandle}scope) $powWCSList($graphHandle)
set powWCSName(${graphHandle}scope) 0
set powPlotParam(wcsName,$graphHandle) "WCS"
set powWCS($graphHandle) $powWCS(c1_$graphHandle)
set powWCS(${graphHandle}scope) $powWCS(c1_$graphHandle)
set powFitsHeader($graphHandle) $powFitsHeader(c1_$graphHandle)
set powFitsHeaderCnt($graphHandle) $powFitsHeaderCnt(c1_$graphHandle)
set powFitsHeader(${graphHandle}scope) $powFitsHeader(c1_$graphHandle)
set powFitsHeaderCnt(${graphHandle}scope) $powFitsHeaderCnt(c1_$graphHandle)
set powPlotColumnDataName($graphHandle) $powPlotColumnDataName(c1_$graphHandle)
set powPlotParam(graphType,$graphHandle) [string tolower [lindex [$fFile getTableInfo hdutype] 0]]
set powPlotParam(graphType,${graphHandle}scope) $powPlotParam(graphType,$graphHandle)
set powPlotParam(zoomed,$graphHandle) 0
set powPlotParam(zoomed,${graphHandle}scope) 0
set xCount($graphHandle) 0
set yCount($graphHandle) 0
set xCount(${graphHandle}scope) 0
set yCount(${graphHandle}scope) 0
if { $inCurrGraph_ && [powGetCurrentGraph]!="" } {
powAddCurves [powGetCurrentGraph] $curves
} else {
if { $powFitsHeader($graphHandle) == "" } {
set useWCSInfo($graphHandle) 0
set useWCSInfo(${graphHandle}scope) 0
}
set errorFlag [ catch { powCreateGraph $graphHandle $curves NULL $xUnit $yUnit \
$xColumn_ $yColumn_ \
[lindex $fvPref::graphDispSize 0] [lindex $fvPref::graphDispSize 1] } err]
if { $errorFlag } {
catch { powDeleteGraph $graphHandle NOPROMPT
powDeleteImage $graphHandle $graphHandle
powDeleteCurve $graphHandle curve }
set wcsinfo ""
set powWCS($curveName) {{0.0 0.0} {0.0 0.0} {1.0 -0.0 0.0 1.0} {{} {}} {{} {}}}
set powFitsHeader($curveName) ""
set powFitsHeaderCnt($curveName) 0
set powWCS($graphHandle) {{0.0 0.0} {0.0 0.0} {1.0 -0.0 0.0 1.0} {{} {}} {{} {}}}
set powWCS(${graphHandle}scope) $powWCS($curveName)
set powFitsHeader($graphHandle) $powFitsHeader($curveName)
set powFitsHeaderCnt($graphHandle) $powFitsHeaderCnt($curveName)
set powFitsHeader(${graphHandle}scope) $powFitsHeader($curveName)
set powFitsHeaderCnt(${graphHandle}scope) $powFitsHeaderCnt($curveName)
set powPlotParam(FixedAspect,$graphHandle) "no"
set xCount($graphHandle) 0
set yCount($graphHandle) 0
set xCount(${graphHandle}scope) 0
set yCount(${graphHandle}scope) 0
set errorFlag [ catch { powCreateGraph $graphHandle $curves NULL $xUnit $yUnit \
$xColumn $yColumn \
[lindex $fvPref::graphDispSize 0] [lindex $fvPref::graphDispSize 1] } err ]
if { $errorFlag } {
tk_messageBox -icon error -type ok -message "Can't plot graph"
return
}
}
}
if { $xColumn_ == "ElementNumber" || $yColumn_ == "ElementNumber" ||
$xColumn_ == "RowNumber" || $yColumn_ == "RowNumber" } {
powSetCurveOptions $graphHandle $curves pDisp No lDisp Yes
} else {
#puts "exprData(x,name1): $exprData(x,name1)"
#puts "exprData(y,name1): $exprData(y,name1)"
# we need to determine if xColumn_ or yColumn_ increased monotonic
set key [$fFile getKeyword NAXIS2]
set value "[string trim [lindex [lindex $key 0] 1] {' ()}]"
regsub -all {[a-zA-Z]} $value {} lRow
#puts "value: $value"
# set lRow [string range $value 0 [expr [string length $value] - 2]]
# set lRow $value
set checkFlag PASSED
set range "1-$lRow"
#puts "_listPreSelectedColNames: $_listPreSelectedColNames"
foreach name $_listPreSelectedColNames {
if { [string first $name $inputXcolumn] >= 0 } {
# if { $name != $inputXcolumn} {
# set checkFlag FAILED
# }
set searchX $name
}
if { [string first $name $inputYcolumn] >= 0 } {
# if { $name != $inputYcolumn} {
# set checkFlag FAILED
# }
set searchY $name
}
}
if [info exists searchX] {
set dataX [$fFile getVectorTableAsRawList $searchX 1 $range]
set dataY [$fFile getVectorTableAsRawList $searchY 1 $range]
# first step, compare the first two elements
foreach dataList [list $dataX $dataY] {
if { $checkFlag == "FAILED" } break
set tokens [split $dataList " "]
set direction up
set previousValue -99
if { [lindex $tokens 0] > [lindex $tokens 1] } {
set direction down
set previousValue 9999999
}
set i 1
foreach value $tokens {
incr i
if { $direction == "down" && $value > $previousValue } {
set checkFlag FAILED
break
}
if { $direction == "up" && $value < $previousValue } {
set checkFlag FAILED
break
}
set previousValue $value
}
if { $checkFlag == "PASSED" } break
}
}
if { $checkFlag == "FAILED" } {
powSetCurveOptions $realGraphHandle $curves pDisp Yes lDisp No
} else {
if { $xeColumn_ != "" || $yeColumn_ != "" } {
powSetCurveOptions $realGraphHandle $curves pDisp Yes lDisp No
} else {
powSetCurveOptions $realGraphHandle $curves pDisp No lDisp Yes
}
}
}
if [info exist xo] {
powMoveGraphTo $graphHandle $xo $yo .pow.pow
foreach el [list xo yo graphWidth graphHeight xmagstep ymagstep] {
unset powPlotParam($el,$oldplot)
}
powDeleteGraph $oldplot NOPROMPT
powDeleteImage $oldplot $oldplot
powDeleteCurve $oldplot curve
# set _graphIDhighest [expr $_graphIDhighest - 1]
powReconfigureToplevel 1
}
if { [info exists xFactor] && [info exists yFactor] } {
powStretchGraph $graphHandle $xFactor $yFactor
}
incr _graphIDhighest
}
itcl::body Table::_relocateDividLine {x_ index_ } {
# note index_ is not used, but I don't know why --Han
set dx [expr $x_ - $_startX]
set _startX $x_
$_droot.table.can move tmpLine $dx 0
}
itcl::body Table::_startDividLine {x_ index_ } {
# note index_ is not used, but I don't know why --Han
if { $x_ > $_endX } {
set _endX $x_
}
$_droot.table.can create line $x_ 0 $x_ $_DC(ysize) \
-width 4 -fill red -tag tmpLine
set _startX $x_
}
itcl::body Table::_finalDividLine {x_ index_} {
# note index_ *is* used in this method
#puts "finalDividLine start"
global g_charPix
$_droot.table.can delete tmpLine
set dx [expr $x_ - $_xPos($index_)]
if { $index_ == 0} {
set moveX $dx
set _DC(width) [expr $_DC(width)+$dx]
$_droot.table.can move check [expr $moveX/2] 0
$_droot.table.can itemconfigure check -width $_DC(width)
# _DC(width) is an important param. it will effect several other things.
# Need to do extra here
_calAbsXPos
_calXPos $_firstCol $_showCols
_getLastFirstCol
} else {
set prIndex [expr $index_ -1 ]
set dx1 [expr $x_ - $_xPos($prIndex)]
set prAbsIndex [expr $prIndex + $_firstCol -1 ]
if { [expr abs($dx)] < $g_charPix} return
if { $x_ < $_xPos($prIndex) } return
set tmp $_cellPixWidth($prAbsIndex)
set _cellWidth($prAbsIndex) [expr $dx1/$g_charPix ]
_calAbsXPos
set moveX [expr $_cellPixWidth($prAbsIndex) -$tmp]
_calXPos $_firstCol $_showCols
_getLastFirstCol
$_droot.table.hdr itemconfigure tempColData_$prIndex \
-width $_cellPixWidth($prAbsIndex)
$_droot.table.can itemconfigure entry_$prIndex \
-width $_cellPixWidth($prAbsIndex)
$_droot.table.can move entry_$prIndex [expr $moveX/2] 0
if [winfo exists $_droot.table.can.tdim${prIndex}_0] {
$_droot.table.can itemconfigure tdim_$prIndex \
-width $_cellPixWidth($prAbsIndex)
$_droot.table.can move tdim_$prIndex [expr $moveX/2] 0
}
$_droot.table.hdr move tempColData_$prIndex [expr $moveX/2] 0
}
for {set i $index_} {$i <= $_showCols} {incr i} {
$_droot.table.can move colLine_$i $moveX 0
$_droot.table.can move entry_$i $moveX 0
if [winfo exists $_droot.table.can.tdim${i}_0] {
$_droot.table.can move tdim_$i $moveX 0
}
$_droot.table.hdr move tempColData_$i $moveX 0
}
_setHScroll [expr $_firstCol-1]
set _endX 0
_reframe
}
itcl::body Table::_calXPos {fCol_ nCols_} {
#puts "_calXPos start"
set errExt [ catch {set key [$fFile getKeyword EXTNAME ]} ]
if { $errExt == 0 && [string first "GROUPING" $key] >= 0 } { set errExt true }
if { $errExt == "true" } {
set _xPos(0) [expr [expr $_DC(lmar) + $_DC(width) + \
$_DC(rightspace)] * 2 + $_DC(width)/4]
} else {
set _xPos(0) [expr $_DC(lmar) + $_DC(width) + $_DC(rightspace)]
}
set tmpPos $_absXPos([expr $fCol_-1])
for {set i 0} {$i < $nCols_} {incr i} {
set colIndex [expr $fCol_+$i]
set _xPos([expr $i+1]) [expr $_absXPos($colIndex)-$tmpPos+$_xPos(0)]
}
}
itcl::body Table::_colMenu { hdr i colName colNum } {
catch { destroy $_droot.table.hdr.menu$i.menu }
catch { destroy $_droot.table.hdr.menu$i.viewcolmenu }
catch { destroy $_droot.table.hdr.menu$i.sort }
if { [catch {$hdr.menu$i configure -text "Modify" -menu $hdr.menu$i.menu}] } {
menubutton $hdr.menu$i -text "Modify" \
-relief raised -font g_titleFont -menu $hdr.menu$i.menu
}
menu $hdr.menu$i.menu -tearoff False
$hdr.menu$i.menu add cascade -label "Sort" \
-menu $hdr.menu$i.menu.sort \
-underline 0 -font g_titleFont
menu $hdr.menu$i.menu.sort -tearoff False
$hdr.menu$i.menu.sort add command -label "Ascending" \
-underline 0 -command [itcl::code $this doSort $colName 1 0 ] \
-font g_titleFont
$hdr.menu$i.menu.sort add command -label "Descending" \
-underline 0 -command [itcl::code $this doSort $colName 0 0 ] \
-font g_titleFont
menu $hdr.menu$i.menu.showcol -tearoff False
set ct 0
set columnbreak 0
foreach name $_unViewedColNames {
$hdr.menu$i.menu.showcol add command -columnbreak $columnbreak \
-label "$name" -underline 0 -font g_titleFont \
-command [itcl::code $this _addColView $name $colName "after"]
set columnbreak 0
incr ct
if { $ct >= 20 } {
set columnbreak 1
set ct 0
}
}
menu $hdr.menu$i.menu.jumpto -tearoff False
$hdr.menu$i.menu.jumpto add command \
-label "Beginning of Table" -underline 0 -font g_titleFont \
-command [itcl::code $this _jumpTo 0]
set ct 0
set columnbreak 0
set _otherColNameList {}
foreach name $_listPreSelectedColNames {
if { $name != $colName } {
lappend _otherColNameList $name
}
}
foreach name $_otherColNameList {
$hdr.menu$i.menu.jumpto add command -columnbreak $columnbreak \
-label "$name" -underline 0 -font g_titleFont \
-command [itcl::code $this _jumpTo $name]
set columnbreak 0
incr ct
if { $ct >= 20 } {
set columnbreak 1
set ct 0
}
}
$hdr.menu$i.menu.jumpto add command \
-label "End of Table" -underline 0 -font g_titleFont \
-command [itcl::code $this _jumpTo "end"]
$hdr.menu$i.menu add cascade \
-label "Jump To Column.." -underline 0 -font g_titleFont \
-menu $hdr.menu$i.menu.jumpto
if { [llength $_listPreSelectedColNames] <= 1 } {
$hdr.menu$i.menu entryconfigure 2 -state disabled
}
menu $hdr.menu$i.menu.movebefore -tearoff False
set ct 0
set columnbreak 0
set _otherColNameList {}
foreach name $_listPreSelectedColNames {
if { $name != $colName } {
lappend _otherColNameList $name
}
}
foreach name $_otherColNameList {
$hdr.menu$i.menu.movebefore add command -columnbreak $columnbreak \
-label "$name" -underline 0 -font g_titleFont \
-command [itcl::code $this _moveColView $colName $name before]
set columnbreak 0
incr ct
if { $ct >= 20 } {
set columnbreak 1
set ct 0
}
}
$hdr.menu$i.menu.movebefore add command \
-label "End of Table" -underline 0 -font g_titleFont \
-command [itcl::code $this _moveColView $colName "END" after]
$hdr.menu$i.menu add cascade \
-label "Move Before.." -underline 0 -font g_titleFont \
-menu $hdr.menu$i.menu.movebefore
$hdr.menu$i.menu add cascade \
-label "Show Column... " -underline 0 -font g_titleFont \
-menu $hdr.menu$i.menu.showcol
if { [llength $_unViewedColNames] <= 0 } {
$hdr.menu$i.menu entryconfigure 3 -state disabled
}
$hdr.menu$i.menu add command -label "Hide Column" \
-underline 0 -command [itcl::code $this _delColView $colName ] \
-font g_titleFont
if { [llength $_listPreSelectedColNames] <= 1 } {
$hdr.menu$i.menu entryconfigure 4 -state disabled
}
$hdr.menu$i.menu add command -label "Insert New Column..." \
-underline 0 -font g_titleFont \
-command [itcl::code $this _addCols [expr $i + 1]]
$hdr.menu$i.menu add command -label "Delete..." \
-underline 0 -command [itcl::code $this _tryDelCols $colName ] \
-font g_titleFont
$hdr.menu$i.menu add command -label "Parameters..." \
-underline 0 -command [itcl::code $this _editColParamsWindow $colNum ] \
-font g_titleFont
}
itcl::body Table::_moveColView { colName targetName option } {
_delColView $colName
_addColView $colName $targetName $option
}
itcl::body Table::_updateUnViewedColumns {} {
set _unViewedColNames {}
if { [catch { set tmplist $_listColNames }] == 0 } {
foreach name $_listColNames {
set tmpPos [lsearch -exact $_listPreSelectedColNames $name]
if { $tmpPos == -1 } {
lappend _unViewedColNames $name
}
}
}
}
itcl::body Table::_drawTableFrame {} {
global g_titleFont
set hdr $_droot.table.hdr
set can $_droot.table.can
set _expandFlag false
# calculate the _xPos
_calXPos $_firstCol $_showCols
#puts "tableType: $_tableType"
#puts "showCols: $_showCols"
set deleteFlag false
if { ($_tableType == "Image") || ($_tableType == "Vector Table") } {
for {set i 0} {$i < $_showCols } {incr i} {
set tmpColName [lindex $_listPreSelectedColNames [expr $_firstCol-1+$i]]
set tmpColNum [expr $_firstCol-1+$i]
set tmpColWid($i) $_cellPixWidth($tmpColNum)
set tmpColXPos($i) [expr $_xPos($i) + $_cellPixWidth($tmpColNum)/2 ]
if [winfo exists $hdr.name$i] {
destroy $hdr.name$i
set deleteFlag true
}
checkbutton $hdr.name$i -text $tmpColName -font g_titleFont \
-variable [itcl::scope _colSel($this,$i)] \
-selectcolor $fvPref::checkBBgColor \
-activeforeground black -activebackground $fvPref::globalBgColor \
-command [itcl::code $this _updateColSel $i]
$hdr create window $tmpColXPos($i) \
[expr $_DC(height)/2] -width $_cellPixWidth($i) \
-window $hdr.name$i -tags tempColData_$i
}
# presumably more standard "Table" tables
} else {
set _fitsFileLocationCol [lsearch -exact $_listPreSelectedColNames "MEMBER_LOCATION"]
_updateUnViewedColumns
for {set i 0} {$i < $_showCols} {incr i} {
set tmpColNum [expr $_firstCol-1+$i]
set tmpColName [lindex $_listPreSelectedColNames $tmpColNum ]
set tmpColXPos($i) [expr $_xPos($i) + $_cellPixWidth($tmpColNum)/2 ]
set tmpColWid($i) $_cellPixWidth($tmpColNum)
if [winfo exists $hdr.name$i] {
catch { destroy $hdr.name$i }
catch { destroy $hdr.type$i }
catch { destroy $hdr.unit$i }
catch { destroy $hdr.vecB$i }
catch { destroy $hdr.menu$i }
set deleteFlag true
}
checkbutton $hdr.name$i -text $_columnName($tmpColNum) \
-font g_titleFont -variable [itcl::scope _colSel($this,$i)] \
-selectcolor $fvPref::checkBBgColor \
-activeforeground black -activebackground $fvPref::globalBgColor \
-command [itcl::code $this _updateColSel $i]
label $hdr.type$i -text $_columnType($tmpColNum) \
-font g_titleFont
label $hdr.unit$i -text $_columnUnit($tmpColNum) \
-font g_titleFont
# Create column header menu
_colMenu $hdr $i $tmpColName $tmpColNum
if { $_columnVecSize($tmpColNum) > 1 || $_columnVecSize($tmpColNum) < 0 } {
$hdr.menu$i.menu insert 0 command \
-label "Expand" -underline 0 -font g_titleFont \
-command [itcl::code $this _openVectorTable $tmpColNum]
set _expandFlag true
}
$hdr create window $tmpColXPos($i) [expr $_DC(height)/2] \
-width $tmpColWid($i) \
-window $hdr.name$i -tags tempColData_$i
$hdr create window $tmpColXPos($i) [expr $_DC(height)*3/2] \
-width $tmpColWid($i) \
-window $hdr.type$i -tags tempColData_$i
$hdr create window $tmpColXPos($i) [expr $_DC(height)*5/2] \
-width $tmpColWid($i) \
-window $hdr.unit$i -tags tempColData_$i
# CM Begin
$hdr create window $tmpColXPos($i) [expr $_DC(height)*7/2] \
-width $tmpColWid($i) \
-window $hdr.menu$i -tags tempColData_$i
# CM End
# $hdr create window $tmpColXPos($i) [expr $_DC(height)*9/2] \
# -width $tmpColWid($i) \
# -window $hdr.vecB$i -tags tempColData_$i
}
}
set _yPos(0) $_DC(tmar)
# Ziqin
# _updateNumRows
_initSelRows
if { $deleteFlag == "true" } {
catch { destroy $hdr.lselAll }
catch { destroy $hdr.selAll }
catch { destroy $hdr.selInvert }
}
label $hdr.lselAll -text "Select" \
-font g_titleFont
$hdr create window [expr $_DC(lmar)+25+[$hdr.lselAll cget -width]/2] [expr $_DC(height)*3/2] \
-width [expr [$hdr.lselAll cget -width]] -height [expr $_DC(height)-1] \
-window $hdr.lselAll -tags check
checkbutton $hdr.selAll -text "All" \
-font g_titleFont \
-variable [itcl::scope _selectAllRows ] \
-selectcolor $fvPref::checkBBgColor \
-activeforeground black -activebackground $fvPref::globalBgColor \
-command [itcl::code $this _selAllRows ]
button $hdr.selInvert -text "Invert" \
-font g_titleFont \
-justify left \
-activeforeground black -activebackground $fvPref::globalBgColor \
-command [itcl::code $this _selInvert ]
$hdr create window [expr $_DC(lmar)+25+[$hdr.selAll cget -width]/2] \
[expr $_DC(height)*5/2] -window $hdr.selAll \
-width [expr [$hdr.selAll cget -width]] -height [expr $_DC(height)-1] \
-tags check
$hdr create window [expr $_DC(lmar)+25+[$hdr.selInvert cget -width]/2] \
[expr $_DC(height)*7/2] -window $hdr.selInvert \
-width [expr [$hdr.selInvert cget -width]] -height [expr $_DC(height)-1] \
-tags check
set indexwidth 56
# puts $indexwidth
# if { $indexwidth < $_DC(width) } {
# set indexwidth $_DC(width)
# }
# puts $_DC(width)
#
# -width [expr $_DC(width)*2] -height [expr $_DC(height)-1]
# $hdr create window [expr $_DC(lmar)+$_DC(width)]
for {set j 0} {$j < $_showRows} {incr j} {
set realRowNum [expr $_firstRow+$j]
if { $_tableType == "Image"} {
set rowIndex [expr $_numRows - $realRowNum+1]
} else {
set rowIndex $realRowNum
}
if { $deleteFlag == "true" } {
catch { destroy $can.b$j }
}
label $can.b$j -text $rowIndex -font g_titleFont
# Modify by Ziqin Pan , Jan 2004
bind $can.b$j <Button-1> [itcl::code $this _setRowStartMark $j]
bind $can.b$j <Button-3> [itcl::code $this _setRowEndMark $j]
bind $can.b$j <Shift-Button-1> [itcl::code $this _setRowEndMark $j]
bind $can.b$j <Button-2> [itcl::code $this _unsetRowMark ]
# Modify end
set _yPos([expr $j+1]) [expr $_DC(tmar) + ($j+1)*($_DC(height) + $_DC(interline))]
$can create window [expr $_DC(lmar)+$_DC(width)/2] \
[expr $_yPos($j)+$_DC(height)/2] -window $can.b$j \
-width $_DC(width) -height [expr $_DC(height)-1] \
-tags check
# $can create window [expr $_DC(lmar)+$indexwidth/2] \
# [expr $_yPos($j)+$_DC(height)/2] -window $can.b$j \
# -width $indexwidth -height [expr $_DC(height)-1] \
# -tags check
if { [catch {set key [$fFile getKeyword EXTNAME]}] == 0 } {
if { [string first "GROUPING" $key] >= 0 } {
if { $deleteFlag == "true" } {
catch { destroy $can.button$realRowNum }
}
button $can.button$realRowNum -text "Open" \
-font [list Helvetica 10 bold] \
-command [itcl::code $this _openGroupFile $_fitsFileLocationCol $realRowNum]
# create consistence OPEN button
$can create window [expr $_DC(width)*2+$_DC(lmar)-10] \
[expr $_yPos($j)+$_DC(height)/2] \
-window $can.button$realRowNum \
-height [expr $_DC(height)-5] \
-tags open_$j
}
}
}
# set the row divide line size
set _DC(xsize) [expr $_DC(xsize) + $_DC(width) + $_DC(lmar) + 12 ]
set tmpHeight [expr $_DC(height) -1]
for {set j 0} {$j < $_showRows } {incr j} {
set tmpColYPos($j) [expr $_yPos($j)+$_DC(height)/2]
for {set i 0} {$i < $_showCols} {incr i} {
set id ${i}_$j
if { $deleteFlag == "true" } {
catch { destroy $can.e$id }
}
entry $can.e$id -width $_cellWidth($i) -state disabled \
-disabledforeground black \
-disabledbackground $fvPref::globalBgColor \
-textvariable [itcl::scope _numEntry($id)] \
-relief sunken -bd 0 -justify right -font g_entryFont
# -textvariable [itcl::scope _numEntry($id)] \
#hello
bind $can.e$id <Button-1> [itcl::code $this _setStartMark $i $j]
bind $can.e$id <Button-3> [itcl::code $this _setEndMark $i $j]
bind $can.e$id <Shift-Button-1> [itcl::code $this _setEndMark $i $j]
bind $can.e$id <Button-2> [itcl::code $this _unsetMark ]
set _buttonWidth 0
if { $_valueTDIM($i) > 0 } {
set slice $j
#puts "_valueTDIM($i) = $_valueTDIM($i)"
if { $deleteFlag == "true" } {
catch { destroy $can.tdim$id }
}
switch $_valueTDIM($i) {
1 {
button $can.tdim$id -text "Plot" \
-font [list Helvetica 10] \
-command [itcl::code $this _plotVectorTableRow $i $slice]
}
2 {
button $can.tdim$id -text "Image" \
-font [list Helvetica 10] \
-command [itcl::code $this _displaySlice $i $slice]
}
3 {
button $can.tdim$id -text "Movie" \
-font [list Helvetica 10] \
-command [itcl::code $this _displayMovie $i $slice]
}
default {
button $can.tdim$id -text "Expand" \
-font [list Helvetica 10] \
-command [itcl::code $this _openVectorTable $i]
}
}
set _buttonWidth [winfo reqwidth $can.tdim$id]
$can create window $tmpColXPos($i) $tmpColYPos($j) \
-window $can.tdim$id \
-width $tmpColWid($i) \
-height $tmpHeight \
-tag tdim_$i
}
$can create window $tmpColXPos($i) $tmpColYPos($j) \
-height $tmpHeight \
-width $tmpColWid($i) \
-window $can.e$id -tags entry_$i
set _xPos([expr $i + 1]) $tmpColXPos($i)
}
}
_reframe
}
itcl::body Table::_redrawTable {prevCols_} {
_calXPos $_firstCol $_showCols
# Reposition/Resize the header/cells
set minCols [getmin [list $prevCols_ $_showCols]]
set idx [expr $_firstCol-1]
for {set i 0} {$i < $minCols } {incr i; incr idx} {
foreach {oldx oldy} [$_droot.table.can coord entry_$i] {}
set entryExist true
if ![info exist oldx] {
set entryExist false
foreach {oldx oldy} [$_droot.table.hdr coord tempColData_$i] {}
}
set dx [expr $_xPos($i)+$_cellPixWidth($idx)/2 - $oldx]
if { $entryExist == "false" } {
unset oldx
}
$_droot.table.can move entry_$i $dx 0
if [winfo exists $_droot.table.can.tdim${i}_0] {
$_droot.table.can move tdim_$i $dx 0
}
$_droot.table.hdr move tempColData_$i $dx 0
$_droot.table.can itemconfigure entry_$i -width $_cellPixWidth($idx)
if [winfo exists $_droot.table.can.tdim${i}_0] {
$_droot.table.can itemconfigure tdim_$i -width $_cellPixWidth($idx)
}
$_droot.table.hdr itemconfigure tempColData_$i -width $_cellPixWidth($idx)
}
# Reposition the last lines
for {set i 0} {$i <= $minCols } {incr i} {
foreach {oldx oldy} [$_droot.table.can coord colLine_$i] {}
set dx [expr $_xPos($i)-$_DC(rightspace)/2-1 - $oldx]
$_droot.table.can move colLine_$i $dx 0
$_droot.table.can raise colLine_$i
}
# Do we need to add/delete any columns?
if { $prevCols_ > $_showCols } {
_delColsFrTable $prevCols_ $_showRows
} elseif { $prevCols_ < $_showCols} {
_addColsToTable $prevCols_ $_showRows
}
}
itcl::body Table::_setVScroll {args} {
#puts "_setVScroll start"
set old_firstRow $_firstRow
# unselected the previously selected cell
_unselCell
#
if { [llength $args]==1 } {
set _firstRow [expr $args+1]
} else {
set stype [lindex $args 2]
set snum [lindex $args 1]
if {$snum == ""} return
if { [string match "page*" $stype] } {
set tmpjump [expr $snum*$_showRows]
} elseif { [string match "unit*" $stype] } {
set tmpjump $snum
} elseif { $stype == ""} {
set tmpjump [expr 1+round($snum*$_numRows)-$_firstRow]
} else {
error "unknown scroll command $stype"
return
}
set _firstRow [expr $_firstRow+$tmpjump]
}
if {$_firstRow < 1} {
set _firstRow 1
}
if {$_firstRow > [expr $_numRows-$_showRows+1] } {
set _firstRow [expr $_numRows-$_showRows+1]
}
_updateLast
_refacing
# reselect cell
_selCell
_showselRows
# Check for locked children
_scrollChildren $_firstRow
}
itcl::body Table::_refacing {} {
#puts "_refacing start"
if { $_numRows } {
$_droot.table.vscroll set [expr double($_firstRow-1)/$_numRows] \
[expr double($_firstRow + $_showRows - 1)/$_numRows]
} else {
$_droot.table.vscroll set 0.0 1.0
}
for {set j 0} {$j < $_showRows} {incr j} {
if { $_tableType == "Image" } {
set rowIndex [expr $_numRows - ($_firstRow+$j) +1]
} else {
set rowIndex [expr $j+$_firstRow]
}
$_droot.table.can.b$j configure -text $rowIndex
# Add by Ziqin Pan , Aug 03, 2005
bind $_droot.table.can.b$j <Button-1> [itcl::code $this _setRowStartMark $j]
bind $_droot.table.can.b$j <Button-3> [itcl::code $this _setRowEndMark $j]
bind $_droot.table.can.b$j <Shift-Button-1> [itcl::code $this _setRowEndMark $j]
bind $_droot.table.can.b$j <Button-2> [itcl::code $this _unsetRowMark ]
# Add end
}
}
itcl::body Table::_setScrolls {} {
#puts "_setScrolls start"
#horizontal
if { $_listPreSelectedColNames == "" } {
$_droot.table.hscroll set 0.0 1.0
} else {
$_droot.table.hscroll set [expr ($_firstCol-1.0)/[llength $_listPreSelectedColNames] ] \
[expr ($_firstCol+$_showCols-1.0)/[llength $_listPreSelectedColNames]]
}
#vertical is set in _refacing
}
itcl::body Table::_setHScroll {args} {
#puts _setHScroll
set _old_firstCol $_firstCol
set oldShowCols $_showCols
set oldShowRows $_showRows
# unselected the cell
_unselCell
if { [llength $args]==1 } {
set _firstCol [expr $args+1]
} else {
set stype [lindex $args 2]
set snum [lindex $args 1]
if {$snum == ""} return
if { [string match "page*" $stype] } {
set tmpjump [expr $snum*$_showCols]
} elseif { [string match "unit*" $stype] } {
set tmpjump $snum
} elseif { $stype == ""} {
set tmpjump [expr 1+round($snum*[llength $_listPreSelectedColNames])-$_firstCol]
} else {
error "unknown scroll command $stype"
return
}
set _firstCol [expr $_firstCol+$tmpjump]
}
if {$_firstCol < 1} {
set _firstCol 1
} elseif {$_firstCol > $_lastFirstCol } {
set _firstCol $_lastFirstCol
}
# determine how many cols and rows to display
_getXYSize $_DC(xsize) $_DC(ysize)
if { [expr $_firstCol+$_showCols-1] > $_dispCols } {
set $_firstCol $_old_firstCol
return
}
_redrawTable $oldShowCols
# update the table entries
_updateLast
_updateUnViewedColumns
if { ($_tableType == "Image") || ($_tableType == "Vector Table")} {
for {set i 0} {$i < $_showCols} {incr i} {
set tmpColNum [expr $_firstCol+$i-1]
set [itcl::scope _colSel($this,$i)] $_colNotchedState($tmpColNum)
set tmpColName [lindex $_listPreSelectedColNames [expr $i+$_firstCol-1]]
$_droot.table.hdr.name$i configure \
-text $tmpColName -command [itcl::code $this _updateColSel $i]
}
} else {
for {set i 0} {$i < $_showCols} {incr i} {
set tmpColName [lindex $_listPreSelectedColNames [expr $i+$_firstCol-1]]
set tmpColNum [expr $_firstCol+$i-1]
set [itcl::scope _colSel($this,$i)] $_colNotchedState($tmpColNum)
$_droot.table.hdr.name$i configure \
-text $_columnName($tmpColNum) -command [itcl::code $this _updateColSel $i]
$_droot.table.hdr.type$i configure \
-text $_columnType($tmpColNum)
$_droot.table.hdr.unit$i configure \
-text $_columnUnit($tmpColNum)
# CM Begin
_colMenu $_droot.table.hdr $i $tmpColName $tmpColNum
if { $_columnVecSize($tmpColNum) > 1 || $_columnVecSize($tmpColNum) < 0 } {
$_droot.table.hdr.menu$i.menu insert 0 command \
-label "Expand" -underline 0 -font g_titleFont \
-command [itcl::code $this _openVectorTable $tmpColNum]
}
}
}
# reselected the previously selected cell
_selCell
_showselRows
#
if { $_listPreSelectedColNames=="" } {
$_droot.table.hscroll set 0.0 1.0
} else {
$_droot.table.hscroll set [expr ($_firstCol-1.0)/[llength $_listPreSelectedColNames] ] \
[expr ($_firstCol+$_showCols-1.0)/[llength $_listPreSelectedColNames]]
}
# justify
_makeJustification
set _endX 0
_reframe
}
itcl::body Table::_addColsToTable {prevCols_ prevRows_} {
set hdr $_droot.table.hdr
set can $_droot.table.can
_calXPos $_firstCol $_showCols
if { ($_tableType == "Image") || ($_tableType == "Vector Table") } {
#puts "prevCols_: $prevCols_"
#puts "_showCols: $_showCols"
for {set i $prevCols_} {$i < $_showCols} {incr i} {
set absColIndex [expr $_firstCol -1+$i]
set tmpColName [lindex $_listPreSelectedColNames $absColIndex]
checkbutton $hdr.name$i -text $tmpColName -font g_titleFont \
-variable [itcl::scope _colSel($this,$i)] \
-selectcolor $fvPref::checkBBgColor \
-activeforeground black -activebackground $fvPref::globalBgColor \
-command [itcl::code $this _updateColSel $i]
$hdr create window [expr $_xPos($i) + \
$_cellPixWidth($absColIndex)/2] \
[expr $_DC(height)/2] -width $_cellPixWidth($absColIndex) \
-window $hdr.name$i -tags tempColData_$i
for {set j 0} {$j < $_showRows } {incr j} {
set id ${i}_$j
if { [winfo exist $can.e$id] == 0} {
entry $can.e$id \
-width $_cellWidth($absColIndex) \
-font g_entryFont -state disabled \
-disabledforeground black \
-disabledbackground $fvPref::globalBgColor \
-textvariable [itcl::scope _numEntry($id)] \
-relief sunken -bd 0 -justify right
bind $can.e$id <Button-1> [itcl::code $this _setStartMark $i $j]
bind $can.e$id <Button-3> [itcl::code $this _setEndMark $i $j]
bind $can.e$id <Shift-Button-1> [itcl::code $this _setEndMark $i $j]
# bind $can.e$id <Button-2> [itcl::code $this _unsetMark]
}
$can create window \
[expr $_xPos($i)+$_cellPixWidth($absColIndex)/2]\
[expr $_yPos($j)+$_DC(height)/2] \
-height [expr $_DC(height) -1] \
-width $_cellPixWidth($absColIndex) \
-window $can.e$id -tags entry_$i
}
}
for {set i $prevCols_} {$i <= $_showCols} {incr i} {
set tmpx [expr $_xPos($i)-$_DC(rightspace)/2-1]
if { $tmpx > $_endX } {
set _endX $tmpx
}
$can create line $tmpx 0 $tmpx $_DC(ysize) -width 3 \
-tags colLine_$i
$can bind colLine_$i <B1-Motion> \
[itcl::code $this _relocateDividLine %x $i]
$can bind colLine_$i <Button-1> \
[itcl::code $this _startDividLine %x $i]
$can bind colLine_$i <ButtonRelease-1> \
[itcl::code $this _finalDividLine %x $i]
}
} else {
if [winfo exists $can] {
for {set c 0} {$c<=[llength $_listPreSelectedColNames]} {incr c} {
for {set r 0} {$r<$_showRows} {incr r} {
catch {destroy $can.tdim${c}_${r}}
}
}
}
_updateUnViewedColumns
for {set i $prevCols_} {$i < $_showCols} {incr i} {
set absColIndex [expr $_firstCol -1+$i]
set tmpColName [lindex $_listPreSelectedColNames $absColIndex]
set tmpColNum [expr $_firstCol-1+$i]
checkbutton $hdr.name$i -text $_columnName($tmpColNum) \
-font g_titleFont \
-variable [itcl::scope _colSel($this,$i)] \
-selectcolor $fvPref::checkBBgColor \
-activeforeground black \
-activebackground $fvPref::globalBgColor \
-command [itcl::code $this _updateColSel $i]
label $hdr.type$i -text $_columnType($tmpColNum) -font g_titleFont
label $hdr.unit$i -text $_columnUnit($tmpColNum) -font g_titleFont
# Create column header menu
_colMenu $hdr $i $tmpColName $tmpColNum
if { $_columnVecSize($tmpColNum) > 1 || $_columnVecSize($tmpColNum) < 0 } {
$hdr.menu$i.menu insert 0 command \
-label "Expand" -underline 0 -font g_titleFont \
-command [itcl::code $this _openVectorTable $tmpColNum]
}
$hdr create window [expr $_xPos($i) + $_cellPixWidth($absColIndex)/2]\
[expr $_DC(height)/2] -width $_cellPixWidth($absColIndex) \
-window $hdr.name$i -tags tempColData_$i
$hdr create window [expr $_xPos($i) + $_cellPixWidth($absColIndex)/2]\
[expr $_DC(height)*3/2 ] -width $_cellPixWidth($absColIndex) \
-window $hdr.type$i -tags tempColData_$i
$hdr create window [expr $_xPos($i) + $_cellPixWidth($absColIndex)/2]\
[expr $_DC(height)*5/2 ] \
-width $_cellPixWidth($absColIndex) \
-window $hdr.unit$i -tags tempColData_$i
# CM Begin
$hdr create window [expr $_xPos($i) + $_cellPixWidth($absColIndex)/2]\
[expr $_DC(height)*7/2 ] \
-width $_cellPixWidth($absColIndex) \
-window $hdr.menu$i -tags tempColData_$i
# CM End
# $hdr create window [expr $_xPos($i) + $_cellPixWidth($absColIndex)/2]\
# [expr $_DC(height)*9/2 ] \
# -width $_cellPixWidth($absColIndex) \
# -window $hdr.vecB$i -tags tempColData_$i
for {set j 0} {$j < $_showRows } {incr j} {
set id ${i}_$j
catch {entry $can.e$id \
-width $_cellWidth($absColIndex) \
-font g_entryFont -state disabled \
-disabledforeground black \
-disabledbackground $fvPref::globalBgColor \
-textvariable [itcl::scope _numEntry($id)] \
-relief sunken -bd 0 -justify right}
bind $can.e$id <Button-1> [itcl::code $this _setStartMark $i $j]
bind $can.e$id <Button-3> [itcl::code $this _setEndMark $i $j]
bind $can.e$id <Shift-Button-1> [itcl::code $this _setEndMark $i $j]
set _buttonWidth 0
if { $_valueTDIM($i) > 0 } {
set slice $j
# catch {$can delete tdim_$i}
# catch {destroy $can.tdim$id}
switch $_valueTDIM($i) {
1 {
button $can.tdim$id -text "Plot" \
-font [list Helvetica 10] \
-command [itcl::code $this _plotVectorTableRow $i $slice ]
}
2 {
button $can.tdim$id -text "Image" \
-font [list Helvetica 10] \
-command [itcl::code $this _displaySlice $i $slice ]
}
3 {
button $can.tdim$id -text "Movie" \
-font [list Helvetica 10] \
-command [itcl::code $this _displayMovie $i $slice ]
}
default {
button $can.tdim$id -text "Expand" \
-font [list Helvetica 10] \
-command [itcl::code $this _openVectorTable $i]
}
}
set _buttonWidth [winfo reqwidth $can.tdim$id]
$can create window \
[expr $_xPos($i)+$_cellPixWidth($absColIndex)/2]\
[expr $_yPos($j)+$_DC(height)/2] \
-window $can.tdim$id \
-width $_cellPixWidth($absColIndex) \
-height [expr $_DC(height)-1] \
-tag tdim_$i
}
$can create window \
[expr $_xPos($i)+$_cellPixWidth($absColIndex)/2]\
[expr $_yPos($j)+$_DC(height)/2] \
-height [expr $_DC(height) -1] \
-width $_cellPixWidth($absColIndex) \
-window $can.e$id -tags entry_$i
set _xPos([expr $i + 1]) [expr $_xPos($i)+$_cellPixWidth($absColIndex)/2]
}
}
for {set i $prevCols_} {$i <= $_showCols} {incr i} {
set tmpx [expr $_xPos($i)-$_DC(rightspace)/2-1]
if { $tmpx > $_endX } {
set _endX $tmpx
}
$can create line $tmpx 0 $tmpx $_DC(ysize) -width 3 \
-tags colLine_$i
$can bind colLine_$i <B1-Motion> \
[itcl::code $this _relocateDividLine %x $i]
$can bind colLine_$i <Button-1> \
[itcl::code $this _startDividLine %x $i]
$can bind colLine_$i <ButtonRelease-1> \
[itcl::code $this _finalDividLine %x $i]
}
}
_setHScroll [expr $_firstCol-1]
}
itcl::body Table::_delColsFrTable {prevCols_ prevRows_} {
set hdr $_droot.table.hdr
set can $_droot.table.can
for {set i $_showCols} {$i < $prevCols_} {incr i} {
$hdr delete tempColData_$i
$can delete entry_$i
$can delete tdim_$i
catch {destroy $hdr.name$i}
catch {destroy $hdr.type$i}
catch {destroy $hdr.unit$i}
catch {destroy $hdr.vecB$i}
catch {destroy $hdr.menu$i}
for {set j 0} {$j < $prevRows_ } {incr j} {
set id ${i}_$j
catch {destroy $can.e$id }
catch {destroy $can.tdim$id }
}
}
for {set i [expr 1+$_showCols]} {$i <= $prevCols_} {incr i} {
$can delete colLine_$i
}
}
itcl::body Table::_addRowsToTable {prevCols_ prevRows_} {
set can $_droot.table.can
_calXPos $_firstCol $_showCols
for {set j $prevRows_} {$j < $_showRows} {incr j} {
set realRowNum [expr $_firstRow + $j]
if { $_tableType == "Image" } {
set rowIndex [expr $_numRows - $realRowNum +1]
} else {
set rowIndex $realRowNum
}
label $can.b$j -text $rowIndex -font g_titleFont
set _yPos([expr $j+1]) [expr $_yPos($j)+ $_DC(height) + $_DC(interline) ]
$can create window [expr $_DC(lmar)+$_DC(width)/2] \
[expr $_yPos($j)+$_DC(height)/2] -window \
$_droot.table.can.b$j \
-width $_DC(width) -height [expr $_DC(height)-1] \
-tags check
if { [catch {set key [$fFile getKeyword EXTNAME]}] == 0 } {
if { [string first "GROUPING" $key] >= 0 } {
button $can.button$realRowNum -text "Open" \
-font [list Helvetica 10 bold] \
-command [itcl::code $this _openGroupFile $_fitsFileLocationCol $realRowNum]
# create consistence OPEN button
$can create window [expr $_DC(width)*2+$_DC(lmar)-10] \
[expr $_yPos($j)+$_DC(height)/2] \
-window $can.button$realRowNum \
-height [expr $_DC(height)-5] \
-tags open_$j
}
}
for {set i 0} {$i < $prevCols_ } {incr i} {
set absColIndex [expr $_firstCol -1 +$i]
set id ${i}_$j
entry $can.e$id -width $_cellWidth($absColIndex) \
-textvariable [itcl::scope _numEntry($id)] -state disabled \
-disabledforeground black \
-disabledbackground $fvPref::globalBgColor \
-relief sunken -bd 0 -justify right -font g_entryFont
bind $can.e$id <Button-1> [itcl::code $this _setStartMark $i $j]
bind $can.e$id <Button-3> [itcl::code $this _setEndMark $i $j]
bind $can.e$id <Shift-Button-1> [itcl::code $this _setEndMark $i $j]
# bind $can.e$id <Button-2> [itcl::code $this _unsetMark]
set _buttonWidth 0
if { $_valueTDIM($i) > 0 } {
set slice $j
# catch {$can delete tdim_$i}
# catch {destroy $can.tdim$id}
switch $_valueTDIM($i) {
1 {
button $can.tdim$id -text "Plot" \
-font [list Helvetica 10] \
-command [itcl::code $this _plotVectorTableRow $i $slice ]
}
2 {
button $can.tdim$id -text "Image" \
-font [list Helvetica 10] \
-command [itcl::code $this _displaySlice $i $slice]
}
3 {
button $can.tdim$id -text "Movie" \
-font [list Helvetica 10] \
-command [itcl::code $this _displayMovie $i $slice]
}
default {
button $can.tdim$id -text "Expand" \
-font [list Helvetica 10] \
-command [itcl::code $this _openVectorTable $i]
}
}
set _buttonWidth [winfo reqwidth $can.tdim$id]
$can create window \
[expr $_xPos($i)+$_cellPixWidth($absColIndex)/2]\
[expr $_yPos($j)+$_DC(height)/2] \
-window $can.tdim$id \
-width $_cellPixWidth($absColIndex) \
-height [expr $_DC(height)-1] \
-tag tdim_$i
}
# set _xPos([expr $i + 1]) [expr $_xPos($i) + $width + 3]
# set width 0
$can create window [expr $_xPos($i)+$_cellPixWidth($absColIndex)/2]\
[expr $_yPos($j)+$_DC(height)/2] \
-height [expr $_DC(height) -1] \
-width $_cellPixWidth($absColIndex) \
-window $can.e$id -tags entry_$i
}
# Pan - change the end X of horizational line
$can create line 0 $_yPos($j) $_endX $_yPos($j) -tags rowLine_$j
# $can create line 0 $_yPos($j) $_DC(xsize) $_yPos($j) -tags rowLine_$j
}
if { $_numRows } {
$_droot.table.vscroll set [expr double($_firstRow-1)/$_numRows] \
[expr ($_firstRow + $_showRows - 1.0)/$_numRows]
} else {
$_droot table.vscroll set 0.0 1.0
}
}
itcl::body Table::_delRowsFrTable {prevCols_ prevRows_} {
#puts "_delRowsFrTable start"
if {$prevRows_ > $_showRows} {
set can $_droot.table.can
for {set j $_showRows} {$j < $prevRows_} {incr j} {
catch {destroy $can.b$j}
catch {destroy $can.button[expr $j+1]}
$can delete rowLine_[expr $j+1]
for {set i 0} {$i < $_showCols } {incr i} {
set id ${i}_$j
catch {destroy $can.e$id }
catch {destroy $can.tdim$id }
}
}
}
_refacing
}
itcl::body Table::_updateLast { } {
set insertButton false
set can $_droot.table.can
# Update visible cells with current values
#puts "_firstCol: $_firstCol"
#puts "_firstRow: $_firstRow"
# _readTableData [expr $_firstCol-1] [expr $_firstRow-1] $_showCols $_showRows
_readTableData [expr $_firstCol-1] [expr $_firstRow-1] \
[llength $_listPreSelectedColNames] $_showRows
set col [expr $_firstCol-1]
# command in fitsTcl
# updateCell
if [winfo exists $can] {
for {set c 0} {$c<=[llength $_listPreSelectedColNames]} {incr c} {
for {set r 0} {$r<$_showRows} {incr r} {
catch {destroy $can.tdim${c}_${r}}
}
}
}
for {set c 0} {$c<$_showCols} {incr c} {
set row [expr $_firstRow-1]
set absColIndex [expr $_firstCol -1 +$c]
for {set r 0} {$r<$_showRows} {incr r} {
set id ${c}_${r}
if [winfo exists $can] {
set oldx 0
set oldy 0
foreach {oldx oldy} [$_droot.table.can coord colLine_$c] {}
if { $_valueTDIM($absColIndex) > 0 } {
set slice $r
switch $_valueTDIM($absColIndex) {
1 {
button $can.tdim${absColIndex}_${r} -text "Plot" \
-font [list Helvetica 10] \
-command [itcl::code $this _plotVectorTableRow $col $slice ]
}
2 {
button $can.tdim${absColIndex}_${r} -text "Image" \
-font [list Helvetica 10] \
-command [itcl::code $this _displaySlice $col $slice]
}
3 {
button $can.tdim${absColIndex}_${r} -text "Movie" \
-font [list Helvetica 10] \
-command [itcl::code $this _displayMovie $col $slice]
}
default {
button $can.tdim${absColIndex}_${r} -text "Expand" \
-font [list Helvetica 10] \
-command [itcl::code $this _openVectorTable $absColIndex]
# $can.tdim$id configure -state disable
}
}
$can create window \
[expr $oldx+$_cellPixWidth($absColIndex)/2 + 6] \
[expr $_yPos($r)+$_DC(height)/2] \
-window $can.tdim${absColIndex}_${r} \
-width $_cellPixWidth($absColIndex) \
-height [expr $_DC(height) -1] \
-tag tdim_$absColIndex
set _xPos([expr $c + 1]) [expr $_xPos($c)+$_cellPixWidth($absColIndex)/2]
}
}
set val [_getFormattedData $col $row]
if { [string length $val]>$_cellWidth($col) } {
# set val "*"
}
set _numEntry($id) $val
incr row
}
incr col
}
}
itcl::body Table::_openGroupFile {c r} {
set fileName [_getRawData $c [expr $_firstRow + $r - 2]]
if { [string range $fileName 0 0] == "/" } {
# full path
set fullPathName $fileName
} else {
set token [split [wm title $_droot ] " "]
set dName [lindex $token [expr [llength $token] - 1]]
set fullPathName [format "%s%s" $dName $fileName]
}
if ![file exists $fullPathName] {
foreach ext { gz Z z zip } {
if [file exists $fullPathName.$ext] {
set fullPathName $fullPathName.$ext
break
}
}
}
set flagErr [catch {
set result [FitsFile #auto $fullPathName 1]
} err]
if { $flagErr } {
tk_messageBox -icon error -type ok -message $err
}
}
itcl::body Table::_jumpFrEnt {} {
#puts "_jumpFrEnt start"
_jump [$_droot.usrEntry.goto_e get]
}
itcl::body Table::_jump {lineNum_} {
#puts "_jump start"
if { $lineNum_ == "" } {
puts "Please give me a number"
return
}
if { $lineNum_<1 } { set lineNum_ 1 }
if { $lineNum_>$_numRows } { set lineNum_ $_numRows }
if { $_tableType == "Image" } {
set realRow [expr $_numRows-$lineNum_]
} else {
set realRow [expr $lineNum_-1]
}
_setVScroll $realRow
if { [info exists _currentCol] } {
_setStartMark [expr $_currentCol-$_firstCol+1] \
[expr $realRow-$_firstRow+1]
} else {
_setStartMark 0 [expr $realRow-$_firstRow+1]
}
}
itcl::body Table::_selRowsFrExpr { ifDelete_ } {
#puts "_selRowsFrExpr start"
# never used, not even initialized
# global g_rowselentry
if { $ifDelete_ } {
set cal ".cald_[namespace tail $this]"
if { [winfo exist $cal] == 1 } {
raise $cal
return
}
# pick out the variable-length vector columns from the calculator
set calList {}
for {set i 0} {$i < $_dispCols} {incr i} {
if { $_columnVecSize($i) > 0 } {
lappend calList [lindex $_listPreSelectedColNames $i]
}
}
FitsDelCalculator $cal $this $calList
$cal configure -title "fv: Delete Rows"
} else {
set cal ".cald_[namespace tail $this]"
if { [winfo exist $cal] == 1 } {
raise $cal
return
}
# pick out the variable-length vector columns from the calculator
set calList {}
for {set i 0} {$i < $_dispCols} {incr i} {
if { $_columnVecSize($i) > 0 } {
lappend calList [lindex $_listPreSelectedColNames $i]
}
}
FitsSelCalculator $cal $this $calList 0 $_numRows
$cal configure -title "fv: Select Rows From Expr"
}
}
itcl::body Table::_addRows {{rowindex -1} { rownum -1} } {
#puts "_addRows start"
global g_titleFont
set addWin .addRow
catch {destroy .addRow}
powToplevel $addWin .dummy
wm title $addWin "fv: Add Rows"
iwidgets::entryfield $addWin.after -textvariable [itcl::scope _rowindex] -labeltext "After row \#" \
-labelpos nw -width 10 -labelfont g_titleFont
iwidgets::entryfield $addWin.number -textvariable [itcl::scope _rownum] -labeltext "Number of rows" \
-labelpos nw -width 10 -labelfont g_titleFont
iwidgets::buttonbox $addWin.bb
if { $rowindex !="" && $rowindex >-1} {
if { $rownum !="" && $rownum > -1 } {
set _rowindex $rowindex
set _rownum $rownum
_addRowsToFile $addWin
return
}
}
$addWin.bb add OK -text OK -command [itcl::code $this _addRowsToFile $addWin] -font g_titleFont
$addWin.bb add Cancel -text Cancel -command "destroy $addWin" -font g_titleFont
pack $addWin.after -fill x
pack $addWin.number -fill x
pack $addWin.bb -fill x
tkwait window $addWin
}
itcl::body Table::_delRowsRange {} {
set selrange ""
set start_end "1-$_numRows"
append selrange [_parseToRowRange $start_end]
if { $selrange !="" } {
for { set i 1 } { $i <= $_numRows } { incr i } {
set _selectedRows($i) 0
}
$fFile delRowsRange $selrange
$fFile changeFile
refresh
_updateRestDisps
}
}
itcl::body Table::_delRows {} {
set ndeleted 0
for {set i 1} {$i <= $_numRows} {incr i} {
if { $_selectedRows($i) == 1 } {
set j $i
while { ($j <=$_numRows) && ($_selectedRows($j) == 1)} {
set _selectedRows($j) 0
incr j
}
set n0 $i
set n1 [expr $j-1]
set nn [expr $j-$i]
$fFile delRows [expr $n0-$ndeleted] $nn
incr ndeleted $nn
if { $_firstRow >= $n1 } {
incr _firstRow [expr -$nn]
} elseif { $_firstRow >= $n0 } {
incr _firstRow [expr -($_firstRow-$n0)]
} else {
}
if { $_firstRow < 1} {
set _firstRow 1
}
set i $j
}
}
set _numRows [expr $_numRows - $ndeleted]
$fFile changeFile
refresh
_updateRestDisps
# puts $_numRows
}
itcl::body Table::_logicalWithselectedRows { rowlist seland selor} {
set sellist {}
for {set i 0} {$i <= $_numRows} {incr i} {
set tmpselrows($i) 0
if { $_selectedRows($i) ==1 } {
lappend sellist $i
}
}
# for {set i 0} {$i < [llength $rowlist]} {incr i} {
# set j [expr 1+[lindex $rowlist $i]]
# set tmpselrows($j) 1
# }
foreach j $rowlist {
set tmpselrows([expr $j+1]) 1
}
if { $seland == 1} {
# for {set i 0} {$i <= $_numRows} {incr i} {
# set _selectedRows($i) [expr $_selectedRows($i) && $tmpselrows($i)]
# }
foreach i $sellist {
set _selectedRows($i) [expr $_selectedRows($i) && $tmpselrows($i)]
}
} elseif { $selor == 1} {
for {set i 0} {$i <= $_numRows} {incr i} {
set _selectedRows($i) [expr $_selectedRows($i) || $tmpselrows($i)]
}
} else {
for {set i 0} {$i <= $_numRows} {incr i} {
set _selectedRows($i) $tmpselrows($i)
}
}
_showselRows
}
itcl::body Table::selRowsWithCondition {cond fRow nRows seland selor} {
#puts "selRowsWithCondition start"
set rowlist [$fFile selRowsWithCondition $cond $fRow $nRows]
_logicalWithselectedRows $rowlist $seland $selor
# set sellist {}
# for {set i 0} {$i <= $_numRows} {incr i} {
# set tmpselrows($i) 0
# if { $_selectedRows($i) ==1 } {
# lappend sellist $i
# }
# }
## for {set i 0} {$i < [llength $rowlist]} {incr i} {
## set j [expr 1+[lindex $rowlist $i]]
## set tmpselrows($j) 1
## }
# foreach j $rowlist {
# set tmpselrows([expr $j+1]) 1
# }
# if { $seland == 1} {
## for {set i 0} {$i <= $_numRows} {incr i} {
## set _selectedRows($i) [expr $_selectedRows($i) && $tmpselrows($i)]
## }
# foreach i $sellist {
# set _selectedRows($i) [expr $_selectedRows($i) && $tmpselrows($i)]
# }
# } elseif { $selor == 1} {
# for {set i 0} {$i <= $_numRows} {incr i} {
# set _selectedRows($i) [expr $_selectedRows($i) || $tmpselrows($i)]
# }
# } else {
# for {set i 0} {$i <= $_numRows} {incr i} {
# set _selectedRows($i) $tmpselrows($i)
# }
# }
# _showselRows
}
itcl::body Table::delRowsWithCondition {cond} {
#puts "delRowsWithCondition start"
$fFile delRowsWithCondition $cond
$fFile changeFile
refresh
_updateRestDisps
}
itcl::body Table::selRowsFromList {entry seland selor} {
# get rid of all the white spaces
regsub -all " " $entry "" tmpEntry
# break it apart
set tmpS [split $tmpEntry ","]
# deal with different parts and make a list
foreach range $tmpS {
if { [regexp {^[0-9]+$} $range] == 1 } {
if {$range <= $_numRows} {
lappend rangeList [list $range $range]
} else {
lappend rangeList [list $_numRows $_numRows]
}
} else {
if {[regsub -- "-" $range "," range1] == 0} {
} else {
set tmpPos [string first "," $range1]
if { $_tableType == "Image"} {
set n1 [expr $_numRows +1 - \
[string range $range1 [expr $tmpPos+1] end ] ]
set n2 [expr $_numRows +1 - \
[string range $range1 0 [expr $tmpPos-1]] ]
} else {
set n1 [string range $range1 0 [expr $tmpPos-1]]
set n2 [string range $range1 [expr $tmpPos+1] end ]
}
if { $n1 < 1 } {
set n1 1
}
if { $n2 > $_numRows } {
set n2 $_numRows
}
if { $n1 > $n2} {
lappend rangeList [list $n2 $n1]
} else {
lappend rangeList [list $n1 $n2]
}
}
}
}
for { set i 0 } {$i <=$_numRows} { incr i} {
set tmplist($i) 0
}
foreach r $rangeList {
set n0 [lindex $r 0]
set n1 [lindex $r 1]
for { set i $n0 } { $i <=$n1 } {incr i} {
set tmplist($i) 1
}
}
if { ($seland !=1) && ($selor !=1) } {
for {set i 0 } { $i <= $_numRows } {incr i} {
set _selectedRows($i) $tmplist($i)
}
} elseif { $seland ==1 } {
for {set i 0 } { $i <= $_numRows } {incr i} {
set _selectedRows($i) [expr $_selectedRows($i) && $tmplist($i)]
}
} else {
foreach r $rangeList {
set n0 [lindex $r 0]
set n1 [lindex $r 1]
for { set i $n0 } { $i <=$n1 } {incr i} {
set _selectedRows($i) 1
}
}
# for {set i 0 } { $i <= $_numRows } {incr i} {
# set _selectedRows($i) [expr $_selectedRows($i) || $tmplist($i)]
# }
}
_showselRows
}
itcl::body Table::delRowsFromList {entry} {
#puts "delRowsFromList start"
# don't delete if its an image extension
if { $_tableType == "Image"} {
error "Cannot delete rows in an image"
return
}
# warning
if { [llength $_listPreSelectedColNames] != [llength $_listColNames] } {
if { [promptMsg "You are editing only part of the table. \n
Do you want to delete rows from all the columns?" \
return Yes No] == "CANCEL"} {
return
}
}
# get rid of all the white spaces
regsub -all " " $entry "" tmpEntry
# break it apart
set tmpS [split $tmpEntry ","]
# deal with different parts and make a list
foreach range $tmpS {
if { [regexp {^[0-9]+$} $range] == 1 } {
if {$range <= $_numRows} {
lappend rangeList [list $range $range]
} else {
lappend rangeList [list $_numRows $_numRows]
}
} else {
if {[regsub -- "-" $range "," range1] == 0} {
} else {
set tmpPos [string first "," $range1]
if { $_tableType == "Image"} {
set n1 [expr $_numRows +1 - \
[string range $range1 [expr $tmpPos+1] end ] ]
set n2 [expr $_numRows +1 - \
[string range $range1 0 [expr $tmpPos-1]] ]
} else {
set n1 [string range $range1 0 [expr $tmpPos-1]]
set n2 [string range $range1 [expr $tmpPos+1] end ]
}
if { $n1 < 1 } {
set n1 1
}
if { $n2 > $_numRows } {
set n2 $_numRows
}
if { $n1 > $n2} {
lappend rangeList [list $n2 $n1]
} else {
lappend rangeList [list $n1 $n2]
}
}
}
}
# now merge the list chosen.
set numRange [llength $rangeList]
set leftList $rangeList
set resultList ""
while { $numRange > 1} {
set seedRange [lindex $leftList 0]
set leftList [lrange $leftList 1 end]
set result [_collapse $seedRange $leftList]
set leftList [lindex $result 1]
if { [lindex $result 0] == 0 } {
lappend resultList $seedRange
}
incr numRange -1
}
lappend resultList [lindex $leftList 0]
set resultList [_sortRange $resultList]
# if deletion happens before the current _firstRow, then the current _firstRow will change.
#
foreach r $resultList {
set n0 [lindex $r 0]
set n1 [lindex $r 1]
set nn [expr $n1-$n0+1]
# really delete rows in the FITS file
$fFile delRows $n0 $nn
$fFile changeFile
if { $_firstRow >= $n1 } {
incr _firstRow [expr -$nn]
} elseif { $_firstRow >= $n0 } {
incr _firstRow [expr -($_firstRow-$n0)]
} else {
}
if { $_firstRow < 1} {
set _firstRow 1
}
}
refresh
_updateRestDisps
}
itcl::body Table::_collapse {seed bed} {
#puts "_collapse start"
set flag 0
set numBedElem [llength $bed]
set sLow [lindex $seed 0]
set sHigh [lindex $seed 1]
# | seed |
# case 1 **|********|**
# case 2 | **** |
# case 3 *****|** |
# case 4 | ***|**
# * bed
for {set i 0} {$i < $numBedElem} {incr i} {
set eLow [lindex [lindex $bed $i] 0]
set eHigh [lindex [lindex $bed $i] 1]
# case 1
if { ($sLow > $eLow) && ($sHigh < $eHigh) } {
set flag 1
# case 2
} elseif {($sLow< $eLow) && ($sHigh > $eHigh)} {
set flag 1
set bed [lreplace $bed $i $i [list $sLow $sHigh]]
# case 3
} elseif {($sLow>=$eLow) && ($sLow<=$eHigh) && ($sHigh>=$eHigh) } {
set flag 1
set bed [lreplace $bed $i $i [list $eLow $sHigh]]
# case 4
} elseif {($sHigh>=$eLow) && ($sHigh<=$eHigh) && ($sLow<=$eLow) } {
set flag 1
set bed [lreplace $bed $i $i [list $sLow $eHigh]]
} else {
}
}
# flag = 1, _collapsed
return [list $flag $bed]
}
itcl::body Table::_sortRange {bed} {
#puts "_sortRange start"
#
# bed should be a list of ranges, and they are not supposed to have overlaps
# overlap has been delt with in _collapse.
#
foreach i $bed {
lappend idxList [lindex $i 0]
}
set sortedList [lsort -decreasing -integer $idxList]
for {set j 0} {$j < [llength $sortedList] } {incr j} {
set tmpIdx [lsearch -exact $idxList [lindex $sortedList $j]]
if { $tmpIdx == -1} {
error "Error sorting"
return
} else {
lappend outList [lindex $bed $tmpIdx]
}
}
# in a reversed order, since cfitsio should delete the last row first
return $outList
}
# Changes contents of a table cell and writes
# it to file if available. col_ and row_ are zero-indexed, indicating
# true row/column of cell to change
#
itcl::body Table::_modifyTableCell {col_ row_ val_} {
#puts "_modifyTableCell start"
if { $isFailedToCopy } return
_writeTableData $col_ $row_ $val_
set id [expr $col_ - $_firstCol + 1]_[expr $row_ - $_firstRow + 1]
set _numEntry($id) [_getFormattedData $col_ $row_]
$fFile changeFile
}
itcl::body Table::_updateColSel {col} {
set realColNum [expr $_firstCol+$col-1]
set _colNotchedState($realColNum) $_colSel($this,$col)
}
itcl::body Table::_resizeCan {x y} {
#puts "_resizeCan start, $x, $y"
set _DC(geoX) [winfo width $_droot]
set _DC(geoY) [winfo height $_droot]
set _DC(geoX0) [winfo x $_droot]
set _DC(geoY0) [winfo y $_droot]
#
_unselCell
#
#puts "screen info: [winfo screenwidth .]"
#puts "_DC(geoX): $_DC(geoX)"
if {$_DC(geoX) < 350 } {
set _DC(geoX) 350
set x 350
}
# wm geometry $_droot [set _DC(geoX)]x[set _DC(geoY)]+[set _DC(geoX0)]+[set _DC(geoY0)]
# Pan Chai - so Table will not jump during resizeCan
wm geometry $_droot [set _DC(geoX)]x[set _DC(geoY)]
set _DC(xsize) $x
set _DC(ysize) $y
$_droot.table.hdr configure -width $_DC(xsize)
$_droot.table.hdr configure -width 10
$_droot.table.can configure -width $_DC(xsize) -height $_DC(ysize)
$_droot.table.can configure -width 10 -height $_DC(ysize)
_getLastFirstCol
# determine number of rows and number of columns to display
_layoutCan $_DC(xsize) $_DC(ysize)
# to prevent _readTableData to be called twice
if { $_justStarted == 1 } {
set _justStarted 0
return
}
_reframe
_refacing
_setScrolls
_updateLast
_selCell
_showselRows
}
itcl::body Table::_reframe {} {
for {set i 0} {$i<=$_showCols} {incr i} {
set _tempXPos($i) $_xPos($i)
}
_calXPos $_firstCol $_showCols
for {set i 0} {$i<=$_showCols} {incr i} {
if { $_tempXPos($i) > $_xPos($i) } {
set _xPos($i) $_tempXPos($i)
}
}
set tmpYPos [expr $_showRows*$_DC(height) + $_DC(tmar) + 1]
for {set i 0} {$i<=$_showCols} {incr i} {
set tmpXPos [expr $_xPos($i)-$_DC(rightspace)/2-1]
if { $i == $_showCols } {
set tmpXPos [expr $_xPos($i)-$_DC(rightspace)/2-1 + 10]
}
$_droot.table.can delete colLine_$i
# Pan - change the end X of horizational line
if { $tmpXPos > $_endX } {
set _endX $tmpXPos
}
$_droot.table.can configure -width [ expr $_xPos($i) + 3 ]
$_droot.table.can create line $tmpXPos 0 $tmpXPos $tmpYPos -width 3 -tags colLine_$i
$_droot.table.can bind colLine_$i <B1-Motion> \
[itcl::code $this _relocateDividLine %x $i]
$_droot.table.can bind colLine_$i <Button-1> \
[itcl::code $this _startDividLine %x $i]
$_droot.table.can bind colLine_$i <ButtonRelease-1> \
[itcl::code $this _finalDividLine %x $i]
}
for {set j 0} {$j<=$_showRows} {incr j} {
$_droot.table.can delete rowLine_$j
# Pan - change the end X of horizational line
# $_droot.table.can create line 0 $_yPos($j) $_DC(xsize) $_yPos($j) -tags rowLine_$j
$_droot.table.can create line 0 $_yPos($j) $_endX $_yPos($j) -tags rowLine_$j
}
_makeJustification
}
itcl::body Table::_getXYSize {x y} {
for {set i $_firstCol} {$i <= $_dispCols} {incr i} {
set tabXSize [expr $_absXPos($i) - $_absXPos([expr $_firstCol-1]) \
+ $_DC(lmar) + $_DC(width) + $_DC(rightspace)/2 ]
if { $tabXSize > $x } break
}
set _showCols [expr $i - $_firstCol]
for {set j 1} {$j <= $_numRows} {incr j} {
set tabYSize [expr 2*$_DC(tmar) + ($j)*($_DC(height) + $_DC(interline))]
if { $tabYSize > $y } break
}
set _showRows [expr $j - 1]
if { $_showRows < 1} {
set _showRows 1
}
if { $_showCols < 1} {
set _showCols 1
}
set lastCol [llength $_listPreSelectedColNames]
if {$_showRows > $_numRows} {
set _showRows $_numRows
}
if {$_showCols > $lastCol} {
set _showCols $lastCol
}
if { $_firstCol > [expr $lastCol -$_showCols+1]} {
set _firstCol [expr $lastCol -$_showCols+1]
}
if { $_firstRow > [expr $_numRows -$_showRows+1]} {
set _firstRow [expr $_numRows -$_showRows+1]
}
}
itcl::body Table::_layoutCan {x y} {
set oldShowCols $_showCols
set oldShowRows $_showRows
set _old_firstCol $_firstCol
_getXYSize $x $y
if { $_showRows > $oldShowRows } {
_addRowsToTable $oldShowCols $oldShowRows
} elseif { $_showRows < $oldShowRows} {
_delRowsFrTable $oldShowCols $oldShowRows
}
_calXPos $_old_firstCol $_showCols
if { $_showCols > $oldShowCols } {
_addColsToTable $oldShowCols $oldShowRows
} elseif { $_showCols < $oldShowCols} {
_delColsFrTable $oldShowCols $oldShowRows
}
}
itcl::body Table::_updateExportPanelState {} {
catch {
if { $_exportsel == 2 } {
.table_saveas.r.frow configure -state normal
.table_saveas.r.lrow configure -state normal
} else {
.table_saveas.r.frow configure -state disable
.table_saveas.r.lrow configure -state disable
}
if { $_exportselc == 2 } {
.table_saveas.r.fcol configure -state normal
.table_saveas.r.lcol configure -state normal
} else {
.table_saveas.r.fcol configure -state disable
.table_saveas.r.lcol configure -state disable
}
}
}
itcl::body Table::trySaveASCII {} {
_saveASCII
}
itcl::body Table::_saveASCII {} {
global g_titleFont
set t [urlTail $fileName]
set r [file root $t]
set e [file ext $t]
if { [lsearch -exact [list .gz .Z .z] $e] != -1 } {
set e [file ext $r]
set r [file root $r]
}
set sugName "${r}_t[expr $currentHDU-1].txt"
set asciiFileName [getSelectedFileName $sugName]
if { $asciiFileName == "" } return
if { [file exist $asciiFileName] == 1 } {
set feedBack [promptMsg "File $asciiFileName exists.\n overwrite?" \
return Yes No]
if { $feedBack == "CANCEL" } return
}
##### saveas table options
catch {destroy .table_saveas}
set fileWin .table_saveas
powToplevel $fileWin .dummy
wm title $fileWin "fv: Export to file options"
if { ($_tableType == "ASCII Table") || ($_tableType == "Binary Table") } {
wm geometry $fileWin 460x420
} else {
wm geometry $fileWin 460x420
}
frame $fileWin.f
iwidgets::feedback $fileWin.f.fdb -labeltext "Saved" -labelfont g_titleFont
pack $fileWin.f.fdb -fill x
iwidgets::buttonbox $fileWin.f.bb
pack $fileWin.f.bb -side top
$fileWin.f.bb add continue -text "Save" \
-command [itcl::code $this _saveTableToAscii $fileWin $asciiFileName] -font g_titleFont
$fileWin.f.bb add quit -text "Cancel" \
-command "destroy $fileWin" -font g_titleFont
## reset these variables
set _exportFirstRow 1
set _exportLastRow $_numRows
set _exportFirstCol 1
set _exportLastCol $_dispCols
set _exportPrintRowNumbers 0
set _exportCSV 1
set _exportCharBetweenCols " "
set _exportFixedFormat 0
set _exportFormat "csv"
frame $fileWin.r
radiobutton $fileWin.r.all \
-text "All" -font g_titleFont \
-variable [itcl::scope _exportsel] -value 1 \
-command [itcl::code $this _updateExportPanelState]
if { ($_tableType == "Image") || ($_tableType == "Vector Table") } {
radiobutton $fileWin.r.range \
-text "From:" -font g_titleFont \
-variable [itcl::scope _exportsel] -value 2 \
-command [itcl::code $this _updateExportPanelState]
}
radiobutton $fileWin.r.sel \
-text "Selection" -variable [itcl::scope _exportsel] \
-font g_titleFont -value 3 \
-command [itcl::code $this _updateExportPanelState]
$fileWin.r.all select
label $fileWin.r.l -text "Rows:"
grid $fileWin.r.l -column 0 -row 0 -pady 10 -padx 20
grid $fileWin.r.all -column 0 -row 1 -sticky w -padx 20
if { ($_tableType == "Image" ) || ($_tableType == "Vector Table") } {
grid $fileWin.r.range -column 0 -row 2 -sticky w -padx 20
}
grid $fileWin.r.sel -column 0 -row 3 -sticky w -padx 20
# not sure if member variables is the best way, or passing variables
# along in a [itcl::code $this type args] way, if that's even possible
if { ($_tableType == "Image") || ($_tableType == "Vector Table") } {
iwidgets::entryfield $fileWin.r.frow -labeltext "" \
-textvariable [itcl::scope _exportFirstRow] \
-textfont g_titleFont -labelfont g_titleFont
iwidgets::entryfield $fileWin.r.lrow -labeltext "To:" \
-textvariable [itcl::scope _exportLastRow] \
-textfont g_titleFont -labelfont g_titleFont
grid $fileWin.r.frow -column 1 -row 2 -sticky w
grid $fileWin.r.lrow -column 2 -row 2 -sticky w
}
pack $fileWin.r -side top
# if user wants to choose columns, he should pre-select using right button
if { ($_tableType == "ASCII Table") || ($_tableType == "Binary Table") || \
($_tableType == "Vector Table") || ($_tableType == "Image")} {
# don't allow user to pick column
radiobutton $fileWin.r.allc \
-text "All" -font g_titleFont \
-variable [itcl::scope _exportselc] -value 1 \
-command [itcl::code $this _updateExportPanelState]
radiobutton $fileWin.r.selc \
-text "Selection" -variable [itcl::scope _exportselc] \
-font g_titleFont -value 2 \
-command [itcl::code $this _updateExportPanelState]
$fileWin.r.allc select
label $fileWin.r.lc -text "Columns:"
if { ($_tableType == "Image") || ($_tableType == "Vector Table") } {
radiobutton $fileWin.r.crange \
-text "From:" -font g_titleFont \
-variable [itcl::scope _exportselc] -value 2 \
-command [itcl::code $this _updateExportPanelState]
iwidgets::entryfield $fileWin.r.fcol -labeltext "" \
-textvariable [itcl::scope _exportFirstCol] \
-textfont g_titleFont -labelfont g_titleFont
iwidgets::entryfield $fileWin.r.lcol -labeltext "To:" \
-textvariable [itcl::scope _exportLastCol] \
-textfont g_titleFont -labelfont g_titleFont
grid $fileWin.r.lc -column 0 -row 4 -pady 10 -padx 20
grid $fileWin.r.allc -column 0 -row 5 -sticky w -padx 20
grid $fileWin.r.crange -column 0 -row 6 -sticky w -padx 20
grid $fileWin.r.fcol -column 1 -row 6 -sticky w
grid $fileWin.r.lcol -column 2 -row 6 -sticky w
} else {
grid $fileWin.r.lc -column 1 -row 0 -pady 10 -padx 50
grid $fileWin.r.allc -column 1 -row 1 -sticky w -padx 50
grid $fileWin.r.selc -column 1 -row 3 -sticky w -padx 50
}
} else {
iwidgets::entryfield $fileWin.fcol -labeltext "First Column:" \
-textvariable [itcl::scope _exportFirstCol] \
-textfont g_titleFont -labelfont g_titleFont
iwidgets::entryfield $fileWin.lcol -labeltext "Last Column:" \
-textvariable [itcl::scope _exportLastCol] \
-textfont g_titleFont -labelfont g_titleFont
pack $fileWin.fcol -side top
pack $fileWin.lcol -side top
}
checkbutton $fileWin.selcb -text "Use Selected Rows" \
-variable [itcl::scope _exportselRows] \
-selectcolor $fvPref::checkBBgColor \
-activeforeground black -activebackground $fvPref::globalBgColor \
-justify left -font g_titleFont
checkbutton $fileWin.cb -text "Print Row Numbers" \
-variable [itcl::scope _exportPrintRowNumbers] \
-selectcolor $fvPref::checkBBgColor \
-activeforeground black -activebackground $fvPref::globalBgColor \
-justify left -font g_titleFont
pack $fileWin.cb -side top -fill x -expand 1
iwidgets::radiobox $fileWin.rb -labeltext "Output Format" \
-selectcolor $fvPref::checkBBgColor \
-foreground black -background $fvPref::globalBgColor -labelfont g_titleFont
if { ($_tableType == "ASCII Table") || ($_tableType == "Binary Table") } {
$fileWin.rb add fixed -text "Fixed Width Columns" -font g_titleFont
}
$fileWin.rb add csv \
-text "CSV format (\"7\",\"8\"...format)" -font g_titleFont
$fileWin.rb add userdefine \
-text "User-defined separator (specify below)" -font g_titleFont
$fileWin.rb select csv
pack $fileWin.rb -fill both
iwidgets::entryfield $fileWin.ins -labeltext \
"Column Separator (for example: , or | ... default is \" \" ):" \
-textvariable [itcl::scope _exportCharBetweenCols] -textfont g_titleFont \
-labelfont g_titleFont
pack $fileWin.ins -side top -fill x -expand 1
pack $fileWin.f -side bottom -fill x
catch {
.table_saveas.r.frow configure -state disable
.table_saveas.r.lrow configure -state disable
.table_saveas.r.fcol configure -state disable
.table_saveas.r.lcol configure -state disable }
}
itcl::body Table::_writeHist { ffile_ origName_ } {
global env
global isWin
set date [clock format [clock seconds] \
-format %Y-%m-%dT%H:%M:%S]
if { [info exists env(USER)] } {
set uname $env(USER)
} elseif { [info exists env(USERNAME)] } {
set uname $env(USERNAME)
} elseif { [info exists env(LOGNAME)] } {
set uname $env(LOGNAME)
} else {
set uname "???"
}
$ffile_ put history " File exported from $origName_ by user \'$uname\' with fv on $date"
}
itcl::body Table::_saveTableToFile {win_ fitsFileName_ origName_} {
set firstrow 0
set delrows 0
set tdelrows 0
if { $_exportsel == 1 } {
$win_.f.fdb configure -steps 1
set _exportLastRow $_numRows
set _exportFirstRow 1
$fFile copyCHDU $fitsFileName_
if {[catch {$win_.f.fdb step}] == 1} {
file delete $fitsFileName_
return
}
set outfFile [fits open $fitsFileName_ 1]
if { $_tableType == "Image" } {
$outfFile move 1
} else {
$outfFile move 2
}
_writeHist $outfFile $origName_
$outfFile checksum update
# $outfFile close
} elseif {$_exportsel == 2} {
$win_.f.fdb configure -steps 2
$fFile copyCHDU $fitsFileName_
set outfFile [fits open $fitsFileName_ 1]
if { $_tableType == "Image" } {
$outfFile move 1
} else {
$outfFile move 2
}
set delrows [expr $_exportFirstRow -1]
set firstrow 1
$outfFile delete rows $firstrow $delrows
if {[catch {$win_.f.fdb step}] == 1} {
file delete $fitsFileName_
return
}
set firstrow [expr $_exportLastRow - $delrows +1]
set delrows [expr $_numRows - $_exportLastRow ]
$outfFile delete rows $firstrow $delrows
if {[catch {$win_.f.fdb step}] == 1} {
file delete $fitsFileName_
return
}
_writeHist $outfFile $origName_
$outfFile checksum update
# $outfFile close
} else {
$fFile copyCHDU $fitsFileName_
set outfFile [fits open $fitsFileName_ 1]
# set outfFile [openFitsFile $fitsFileName_]
if { $_tableType == "Image" } {
$outfFile move 1
} else {
$outfFile move 2
}
set nblock 1
for { set i 1 } {$i <=$_numRows } { incr i } {
if { $_selectedRows($i) == 1 } {
set _selectedRows($i) 0
} else {
set _selectedRows($i) 1
}
}
# set nblock [expr $_numRows/1000000]
# if { $_numRows > [expr $nblock*1000000] } {
# incr nblock
# }
$win_.f.fdb configure -steps $nblock
# for { set i 1 } { $i <=$nblock } { incr i} {
# set start [expr ($i-1)*1000000 +1]
# set end [expr $i*100000]
# if { $end > $_numRows } {
# set end $_numRows
# }
# set start_end "$start-$end"
set start_end "1-$_numRows"
set selrange [_parseToRowRange $start_end]
$outfFile delete rows -range $selrange
if {[catch {$win_.f.fdb step}] == 1} {
file delete $fitsFileName_
return
}
# }
# for { set i 1 } {$i <=$_numRows } { incr i } {
# if { $_selectedRows($i) == 0} {
# incr nblock
# while {$_selectedRows($i) == 0 } {
# incr i
# if { $i > $_numRows} {
# break
# }
# }
# }
# }
# $win_.f.fdb configure -steps $nblock
# for { set i 1 } {$i <=$_numRows } { incr i } {
# if { $_selectedRows($i) == 0} {
# set firstrow [expr $i - $tdelrows]
## puts "first : $i"
# while {$_selectedRows($i) == 0 } {
# incr i
# if { $i > $_numRows} {
# break
# }
# }
## puts "last: $i"
# set delrows [expr $i - $firstrow - $tdelrows]
#
# incr tdelrows $delrows
# $outfFile delete rows $firstrow $delrows
# if {[catch {$win_.f.fdb step}] == 1} {
# file delete $fitsFileName_
# return
# }
# }
# }
# $outfFile put history " Exported from $origName_"
_writeHist $outfFile $origName_
$outfFile checksum update
# $outfFile close
}
set collist {}
if { $_exportcolsel == 2 } {
for {set i 1} { $i < $_exportFirstCol} {incr i} {
lappend collist [lindex $_listPreSelectedColNames [expr $i -1]]
}
for {set i [expr $_exportLastCol +1]} { $i <= $_dispCols} {incr i} {
lappend collist [lindex $_listPreSelectedColNames [expr $i -1]]
}
$outfFile delete cols $collist
} elseif {$_exportcolsel == 3} {
for {set i 0} { $i < $_dispCols} {incr i} {
if {$_colNotchedState($i) == 0} {
lappend collist [lindex $_listPreSelectedColNames $i]
}
}
$outfFile delete cols $collist
}
destroy $win_
}
itcl::body Table::_saveTableToAscii {win_ asciiFileName_} {
# these vars are used
# _exportFirstRow
# _exportLastRow
# _exportFirstCol
# _exportLastCol
# _exportCSV
# _exportPrintRowNumbers
# _exportCharBetweenCols
set _exportFormat [$win_.rb get]
if { $_exportFormat == "csv" } {
set _exportCSV 1
set _exportFixedFormat 0
} elseif { $_exportFormat == "fixed" } {
set _exportCSV 0
set _exportFixedFormat 1
} elseif { $_exportFormat == "userdefine" } {
set _exportCSV 0
set _exportFixedFormat 0
}
set collist {}
set collistwidths {}
# Note: all rows and cols are 1-based
# this matches the $fFile print commands below use 1-based, so no
# change is needed
################################################################
# set up the feedback bar
set totalRowsPrint [expr $_exportLastRow - $_exportFirstRow + 1]
# NOTE -- this is changed to 1000000000 rows
# we will print 1000 rows at a time (or whatever is left)
# numPrintBlocks = total blocks of 1000 or iterations in feedbar bar
# if we have 2835 rows, we'll print:
# 1 to 1000, (first block)
# 1001 to 2000, (second block)
# 2001 to 2835. (third block)
#
# tables are meant to be printed in standard row order
set numPrintBlocks [expr $totalRowsPrint/1000000000]
if { ($totalRowsPrint - $numPrintBlocks*1000000000) > 0 } {
incr numPrintBlocks
}
$win_.f.fdb configure -steps $numPrintBlocks
# create list of print widths
set listPrintWidths {}
for {set i 0} {$i < $_dispCols} {incr i} {
lappend listPrintWidths [expr $_cellWidth($i) + 1]
}
set firstloop 1
if { $_exportsel == 1 } {
set _exportFirstRow 1
set _exportLastRow $_numRows
set totalRowsPrint [expr $_exportLastRow - $_exportFirstRow + 1]
}
if { $_exportsel == 3 } {
for {set r 1} { $r <=$_numRows } { incr r } {
if {$_selectedRows($r) ==1 } {
set _exportFirstRow $r
while { $_selectedRows($r) == 1} {
incr r
if { $r > $_numRows } {
break
}
}
set totalRowsPrint [expr $r - $_exportFirstRow]
for {set n 1} {$n <= $numPrintBlocks} {incr n} {
if { $n == 1 && $firstloop == 1} {
# write into a new file and write column names
set filePrintMode 0
} else {
# append to that file and don't write column names
set filePrintMode 2
}
set fRow [expr 1000000000*[expr $n-1] + 1]
if { $n == $numPrintBlocks } {
set nRows [expr $totalRowsPrint - $fRow + 1]
} else {
set nRows 1000000000
}
# shift by the first user-selected row
set fRow [expr $fRow + $_exportFirstRow - 1]
if { ($_tableType == "ASCII Table") || ($_tableType == "Binary Table") } {
if { $_exportselc == 1 } {
set collist $_listPreSelectedColNames
set collistwidths $listPrintWidths
} else {
set collist {}
set collistwidths {}
for {set i 0} { $i < $_dispCols} {incr i} {
if {$_colNotchedState($i) == 1} {
lappend collist [lindex $_listPreSelectedColNames $i]
lappend collistwidths [lindex $listPrintWidths $i]
}
}
}
$fFile saveTabToASCII $asciiFileName_ $filePrintMode \
$fRow $nRows \
$collist $collistwidths \
$_exportFixedFormat \
$_exportCSV \
$_exportPrintRowNumbers \
$_exportCharBetweenCols
} else {
error "Table Type unknown. Export as text not possible."
return
}
# if user presses cancel, stop
if {[catch {$win_.f.fdb step}] == 1} {
file delete $asciiFileName_
return
}
}
set firstloop 0
}
}
} else {
for {set n 1} {$n <= $numPrintBlocks} {incr n} {
if { $n == 1 } {
# write into a new file and write column names
set filePrintMode 0
} else {
# append to that file and don't write column names
set filePrintMode 2
}
set fRow [expr 1000000000*[expr $n-1] + 1]
if { $n == $numPrintBlocks } {
set nRows [expr $totalRowsPrint - $fRow + 1]
} else {
set nRows 1000000000
}
# shift by the first user-selected row
set fRow [expr $fRow + $_exportFirstRow - 1]
if { ($_tableType == "ASCII Table") || ($_tableType == "Binary Table") } {
if { $_exportselc == 1 } {
set collist $_listPreSelectedColNames
set collistwidths $listPrintWidths
} else {
set collist {}
set collistwidths {}
for {set i 0} { $i < $_dispCols} {incr i} {
if {$_colNotchedState($i) == 1} {
lappend collist [lindex $_listPreSelectedColNames $i]
lappend collistwidths [lindex $listPrintWidths $i]
}
}
}
$fFile saveTabToASCII $asciiFileName_ $filePrintMode \
$fRow $nRows \
$collist $collistwidths \
$_exportFixedFormat \
$_exportCSV \
$_exportPrintRowNumbers \
$_exportCharBetweenCols
} else {
error "Table Type unknown. Export as text not possible."
return
}
# if user presses cancel, stop
if {[catch {$win_.f.fdb step}] == 1} {
file delete $asciiFileName_
return
}
}
}
destroy $win_
}
itcl::body Table::tryExport {} {
_export
}
itcl::body Table::_export {} {
global g_titleFont
set t [urlTail $fileName]
set r [file root $t]
set e [file ext $t]
if { [lsearch -exact [list .gz .Z .z] $e] != -1 } {
set e [file ext $r]
set r [file root $r]
}
set origName "${r}.fits\[[expr $currentHDU-1]\]"
set sugName "${r}_t[expr $currentHDU-1].fits"
set fitsFileName [getSelectedFileName $sugName]
if { $fitsFileName == "" } return
if { [file exist $fitsFileName] == 1 } {
set feedBack [promptMsg "File $fitsFileName exists.\n overwrite?" \
return Yes No]
if { $feedBack == "CANCEL" } return
}
##### saveas table options
catch {destroy .table_saveas}
set fileWin .table_saveas
powToplevel $fileWin .dummy
wm title $fileWin "fv: Export to file options"
if { ($_tableType == "ASCII Table") || ($_tableType == "Binary Table") } {
wm geometry $fileWin 400x350
} else {
wm geometry $fileWin 400x350
}
frame $fileWin.f
iwidgets::feedback $fileWin.f.fdb -labeltext "Saved" -labelfont g_titleFont
pack $fileWin.f.fdb -fill x
iwidgets::buttonbox $fileWin.f.bb
pack $fileWin.f.bb -side top
$fileWin.f.bb add continue -text "Save" \
-command [itcl::code $this _saveTableToFile $fileWin $fitsFileName $origName] -font g_titleFont
$fileWin.f.bb add quit -text "Cancel" \
-command "destroy $fileWin" -font g_titleFont
## reset these variables
set _exportFirstRow 1
set _exportLastRow $_numRows
set _exportFirstCol 1
set _exportLastCol $_dispCols
set _exportPrintRowNumbers 0
set _exportCSV 1
set _exportCharBetweenCols " "
set _exportFixedFormat 0
set _exportFormat "csv"
frame $fileWin.r
frame $fileWin.r.r
frame $fileWin.r.c
trace variable [itcl::scope _exportsel] w _updateExportPanelState
radiobutton $fileWin.r.r.all \
-text "All" -font g_titleFont \
-variable [itcl::scope _exportsel] -value 1 -command [itcl::code $this _updateExportPanelState]
# radiobutton $fileWin.r.range \
# -text "From:" -font g_titleFont -variable [itcl::scope _exportsel] -value 2 \
# -command [itcl::code $this _updateExportPanelState]
radiobutton $fileWin.r.r.sel \
-text "Selection" -variable [itcl::scope _exportsel] -font g_titleFont -value 3 \
-command [itcl::code $this _updateExportPanelState]
$fileWin.r.r.all select
# pack $fileWin.allrb -side top
# pack $fileWin.rangerb -side top
# pack $fileWin.selrb -side top
label $fileWin.r.r.l -text "Rows:"
grid $fileWin.r.r.l -column 0 -row 0 -pady 10 -sticky w
grid $fileWin.r.r.all -column 0 -row 1 -sticky w
# grid $fileWin.r.range -column 0 -row 2 -sticky w
grid $fileWin.r.r.sel -column 0 -row 3 -sticky w
# frame $fileWin.c
radiobutton $fileWin.r.c.all \
-text "All" -font g_titleFont \
-variable [itcl::scope _exportcolsel] -value 1 -command [itcl::code $this _updateExportPanelState]
# radiobutton $fileWin.c.range \
# -text "From:" -font g_titleFont -variable [itcl::scope _exportcolsel] -value 2 \
# -command [itcl::code $this _updateExportPanelState]
radiobutton $fileWin.r.c.sel \
-text "Selection" -variable [itcl::scope _exportcolsel] -font g_titleFont -value 3 \
-command [itcl::code $this _updateExportPanelState]
$fileWin.r.c.all select
# pack $fileWin.allrb -side top
# pack $fileWin.rangerb -side top
# pack $fileWin.selrb -side top
label $fileWin.r.c.l -text "Columns:"
grid $fileWin.r.c.l -column 1 -row 0 -pady 10 -sticky w
grid $fileWin.r.c.all -column 1 -row 1 -sticky w
# grid $fileWin.c.range -column 0 -row 2 -sticky w
grid $fileWin.r.c.sel -column 1 -row 3 -sticky w
# iwidgets::entryfield $fileWin.c.fcol -labeltext "" \
# -textvariable [itcl::scope _exportFirstCol] -textfont g_titleFont -labelfont g_titleFont
# iwidgets::entryfield $fileWin.c.lcol -labeltext "To:" \
# -textvariable [itcl::scope _exportLastCol] -textfont g_titleFont -labelfont g_titleFont
# grid $fileWin.c.fcol -column 1 -row 2 -sticky w
# grid $fileWin.c.lcol -column 2 -row 2 -sticky w
# not sure if member variables is the best way, or passing variables
# along in a [itcl::code $this type args] way, if that's even possible
# iwidgets::entryfield $fileWin.frow -labeltext "First Row:"
# iwidgets::entryfield $fileWin.r.frow -labeltext "" \
# -textvariable [itcl::scope _exportFirstRow] -textfont g_titleFont -labelfont g_titleFont
# iwidgets::entryfield $fileWin.lrow -labeltext "Last Row:"
# iwidgets::entryfield $fileWin.r.lrow -labeltext "To:" \
# -textvariable [itcl::scope _exportLastRow] -textfont g_titleFont -labelfont g_titleFont
# iwidgets::entryfield $fileWin.rowrange -labeltext "Row Range:" \
# -textvariable [itcl::scope _exportRowRange] -textfont g_titleFont -labelfont g_titleFont
# grid .fv_imgsel.label -column 0 -row 0 -columnspan 4 -sticky "snew"
# grid $fileWin.r.frow -column 1 -row 2 -sticky w
# grid $fileWin.r.lrow -column 2 -row 2 -sticky w
# pack $fileWin.frow -side top
# pack $fileWin.lrow -side top
# pack $fileWin.rowrange -side top
# grid $fileWin.r -column 0 -row 0
# grid $fileWin.c -column 1 -row 0
pack $fileWin.r.r -side left -padx 40
pack $fileWin.r.c -side right -padx 40
pack $fileWin.r -side top
# pack $fileWin.c -side top
# if user wants to choose columns, he should pre-select using right button
if { ($_tableType == "ASCII Table") || ($_tableType == "Binary Table") } {
# don't allow user to pick column
} else {
# iwidgets::entryfield $fileWin.fcol -labeltext "First Column:" \
# -textvariable [itcl::scope _exportFirstCol] -textfont g_titleFont -labelfont g_titleFont
# iwidgets::entryfield $fileWin.lcol -labeltext "Last Column:" \
# -textvariable [itcl::scope _exportLastCol] -textfont g_titleFont -labelfont g_titleFont
# pack $fileWin.fcol -side top
# pack $fileWin.lcol -side top
}
# pack $fileWin.f -side bottom -fill x
pack $fileWin.f -side bottom -fill x
# grid $fileWin.f -column 0 -row 7 -columnspan 3 -pady 10 -ipadx 90
}
itcl::body Table::_saveFile {} {
# Save File
$fFile save
_updateHL
}
itcl::body Table::_saveAs {} {
$fFile saveAs
}
itcl::body Table::_updateHL {} {
# Override this function in descendents
}
itcl::body Table::_closeFrWm {w} {
if { $w == $_droot && !$_isBeingDestroyed } {
closeCmd
}
}
itcl::body Table::closeCmd {} {
foreach i $_myChildren {
itcl::delete object $i
}
_updateHL
_realCloseCmd
}
itcl::body Table::setFileName { fName_ } {
# set fileName $fName_
if ![winfo exists $_droot] return
set rName [urlTail $fName_]
set dName [getFullDirPath $fName_]
wm title $_droot "fv: $_tableType of $rName\[[expr $currentHDU-1]\] in $dName"
# wm geometry $_droot 400x200
}
itcl::body Table::_realCloseCmd {} {
# let the winkeeper know it's gone
if { $_isDirPlot == 0 } {
.fvwinkeeper signoff $_droot
}
itcl::delete object $this
}
itcl::body Table::_updateNumRows {} {
#Ziqin Apr 01,04
if { $_tableType == "Image"} {
if { [llength [$fFile getImgInfo]] == 1 } {
set _numRows [lindex [$fFile getImgInfo] 0]
} else {
set _numRows [lindex [$fFile getImgInfo] 1]
}
} else {
set _numRows [$fFile getTableInfo nrows]
}
}
itcl::body Table::_initSelRows {} {
_updateNumRows
for {set i 0} { $i <= $_numRows} {incr i} {
set _selectedRows($i) 0
}
}
itcl::body Table::_updateNumCols {} {
# Do nothing here. Override in subclasses
}
itcl::body Table::_addCols {{colindex -1 } {colname {} } {colformat {}} { colunit {}} {dispformat {}} } {
# Init the variables
set _addcolname ""
set _addcolunit ""
set _addcoldisp ""
set _addcolform ""
set addWin .addCol
catch {destroy .addCol}
powToplevel $addWin .dummy
wm title $addWin "fv : add column info"
wm geometry $addWin +[winfo pointerx .]+[winfo pointery .]
iwidgets::entryfield $addWin.name -labeltext "Column Name" -labelpos w \
-validate "validColName %c" -fixed 68 -width 10 \
-textvariable [itcl::scope _addcolname]
# the format list
if { $_tableType == "Binary Table"} {
set formatList {{1A - ASCII string} {1L - logical (T or F)} \
{1X - bit} {1B - 1 byte unsigned integer} \
{1I - 2 byte integer} {1J - 4 byte integer}\
{1K - 8 byte integer} \
{1E - 4 byte real} {1D - 8 byte double} \
{1C - 8 byte complex} {1M - 16 byte double complex} }
} elseif { $_tableType == "ASCII Table"} {
set formatList \
{{A10 - 10 chars ASCII string} {I10 - 10 digits integer} \
{F10.2 - 10 digits real with two sig digits} \
{E10.2 - 10 digits real with exp} \
{D20.10 - 20 digits double with 10 sig digits}}
} else {
set formatList { }
}
iwidgets::combobox $addWin.form -labeltext "Column Format" -labelpos w \
-textvariable [itcl::scope _addcolform] -completion 0
eval $addWin.form insert list end $formatList
iwidgets::entryfield $addWin.unit -labeltext "Column Unit" -labelpos w \
-fixed 68 -width 10 -textvariable [itcl::scope _addcolunit]
iwidgets::entryfield $addWin.disp -labeltext "Display Format" -labelpos w \
-fixed 68 -width 10 -textvariable [itcl::scope _addcoldisp]
set tmpList $_listPreSelectedColNames
set tmpList [lappend tmpList "End of Table"]
# needs to be reset in case it was altered last time
set _insColNum "End of Table"
iwidgets::combobox $addWin.colist -labeltext "Insert Before" -labelpos w \
-editable 1 -textvariable [itcl::scope _insColNum]
eval $addWin.colist insert list end $tmpList
if { $colindex !=-1 && $colname != "" } {
set _addcolname $colname
set _addcolform $colformat
set _addcolunit $colunit
set _addcoldip $dispformat
if { $colindex == "-" } {
set colindex "End of Table"
}
set _insColNum $colindex
_addColsToFile $addWin
return
}
if { $colindex != -1 } {
$addWin.colist selection clear 0 end
$addWin.colist selection set $colindex
}
grid $addWin.name -row 1 -column 1 -sticky ew -padx 10 -pady 2
grid $addWin.form -row 2 -column 1 -sticky ew -padx 10 -pady 2
grid $addWin.unit -row 3 -column 1 -sticky ew -padx 10 -pady 2
grid $addWin.disp -row 4 -column 1 -sticky ew -padx 10 -pady 2
grid $addWin.colist -row 5 -column 1 -sticky ew -padx 10 -pady 2
iwidgets::Labeledwidget::alignlabels \
$addWin.name $addWin.unit $addWin.form $addWin.colist
iwidgets::buttonbox $addWin.bb
$addWin.bb add OK -text OK -command [itcl::code $this _addColsToFile $addWin]
$addWin.bb add Cancel -text Cancel -command "destroy $addWin"
grid $addWin.bb -row 6 -column 1
tkwait window $addWin
}
itcl::body Table::_addRowsToFile {inWin} {
set rowIdx [$inWin.after get]
set rowNum [$inWin.number get]
regsub -all " " $rowIdx "" tmpIdx
regsub -all " " $rowNum "" tmpNum
# delete the input window
destroy $inWin
if { ($tmpIdx == "") || ($tmpNum == "") } {
error "Please input number"
return
} elseif { $tmpIdx=="end" } {
set tmpIdx $_numRows
}
# We asked for row "after", but CFITSIO inserts "before"
incr tmpIdx
# if { $tmpIdx > $_numRows} {
# $fFile addRow $tmpNum
# } else {
# $fFile insertRow $tmpIdx $tmpNum
# }
if { $tmpIdx > $_numRows} {
$fFile addRow $tmpNum
for { set i 1} { $i <=$tmpNum } {incr i} {
set _selectedRows([expr $i+$_numRows]) 0
}
} else {
$fFile insertRow $tmpIdx $tmpNum
for { set i $_numRows } { $i >= $tmpIdx } { set i [expr $i -1] } {
set _selectedRows([expr $i + $tmpNum]) $_selectedRows($i)
}
for { set i 0 } { $i < $tmpNum } { incr i} {
set _selectedRows([expr $tmpIdx +$i]) 0
}
}
$fFile changeFile
refresh
_updateRestDisps
}
# Add an existing table column to the view
itcl::body Table::_addColView { colName_ addPos_ beforeAfter_ } {
if { $addPos_ == "END" } {
set tmpIdx [llength $_listPreSelectedColNames]
} else {
set tmpIdx [lsearch $_listPreSelectedColNames $addPos_]
if { $beforeAfter_ == "after" } {
incr tmpIdx
}
if { ($tmpIdx == -1) } {
error "No such column: $addPos_"
return
}
}
set _listPreSelectedColNames [linsert $_listPreSelectedColNames $tmpIdx $colName_]
for {set j $_dispCols} {$j > $tmpIdx} {incr j -1} {
set _cellWidth($j) $_cellWidth([expr $j-1])
}
if { $j < $_dispCols } {
unset _cellWidth($j)
}
refresh
}
# Remove the column from the view (but don't delete it from the table)
itcl::body Table::_delColView { colName_ } {
set tmpIdx [lsearch $_listPreSelectedColNames $colName_]
if { ($tmpIdx == -1) } {
error "No such column: $colName_"
return
}
set _listPreSelectedColNames [lreplace $_listPreSelectedColNames $tmpIdx $tmpIdx]
for {set j $tmpIdx} {$j < [expr $_dispCols-1]} {incr j} {
set _cellWidth($j) $_cellWidth([expr $j+1])
}
unset _cellWidth([expr $_dispCols-1])
refresh
}
itcl::body Table::_addColsToFile {inWin} {
#puts "_addColsToFile start"
set addPos $_insColNum
# delete the input window
destroy $inWin
set tmpcolform [lindex $_addcolform 0]
regsub -all " " $_addcolname "" tmpName
regsub -all " " $_addcolunit "" tmpUnit
regsub -all " " $_addcoldisp "" tmpDisp
regsub -all " " $tmpcolform "" tmpForm
if { ($tmpName == "") || ($tmpForm == "")} {
error "Column name/form can't be blank"
return
}
if { $addPos == "End of Table" } {
$fFile addColumn $_addcolname $tmpcolform
lappend _listPreSelectedColNames $_addcolname
lappend _listColNames $_addcolname
if { $tmpUnit != "" } {
$fFile putKwd "TUNIT[llength $_listColNames] '$tmpUnit'" 1
}
if { $tmpDisp != "" } {
$fFile putKwd "TDISP[llength $_listColNames] '$tmpDisp'" 1
}
} else {
set tmpIdx [lsearch $_listPreSelectedColNames $addPos]
set tmpIdx1 [lsearch $_listColNames $addPos]
if { ($tmpIdx == -1) || ($tmpIdx1 == -1)} {
error "No such column"
return
}
$fFile insertCol [expr $tmpIdx1+1] $_addcolname $tmpcolform
set _listPreSelectedColNames [linsert $_listPreSelectedColNames $tmpIdx $_addcolname]
set _listColNames [linsert $_listColNames $tmpIdx1 $_addcolname]
if { $tmpUnit != "" } {
$fFile putKwd "TUNIT[expr $tmpIdx1+1] '$tmpUnit'" 1
}
if { $tmpDisp != "" } {
$fFile putKwd "TDISP[expr $tmpIdx1+1] '$tmpDisp'" 1
}
for {set j $_dispCols} {$j > $tmpIdx} {incr j -1} {
set _cellWidth($j) $_cellWidth([expr $j-1])
}
unset _cellWidth($j)
}
# let the fFile know that the file has been changed
$fFile changeFile
# update the displayed table and children
refresh
_updateRestDisps
}
itcl::body Table::refresh { {doChildren_ 1} } {
if ![info exists _DC(xsize)] return
# Re-read table information
_readInTable
# Check the number of rows and columns in the table
set oldNumCols $_numCols
set oldNumRows $_numRows
_updateNumCols
_updateNumRows
if { $oldNumCols != $_numCols || $oldNumRows != $_numRows } {
_layoutCan $_DC(xsize) $_DC(ysize)
_reframe
}
# recalculate the _firstCol of the last page
_getLastFirstCol
# redraw the table and more
_setHScroll [expr $_firstCol-1]
_refacing
# Update any children of this table, if they exist
if { $doChildren_ } {
foreach child $_myChildren {
$child refresh
}
}
}
itcl::body Table::_delCols {{collist -1}} {
if { $_tableType == "Image"} {
error "Cannot delete columns in an image"
return
}
# clean the cell selection
_unselCell
set delColList {}
set tmpList {}
set j 0
# for {set i 0} { $i < $_dispCols} {incr i} {
# if { $_colNotchedState($i) == 1 } {
# lappend delColList [lindex $_listPreSelectedColNames $i]
# } else {
# lappend tmpList [lindex $_listPreSelectedColNames $i]
# set _cellWidth($j) $_cellWidth($i)
# incr j
# }
# }
for {set i 0} { $i < $_dispCols} {incr i} {
if { $collist == -1} {
if { $_colNotchedState($i) == 1 } {
lappend delColList [lindex $_listPreSelectedColNames $i]
} else {
lappend tmpList [lindex $_listPreSelectedColNames $i]
set _cellWidth($j) $_cellWidth($i)
incr j
}
} else {
if { [lsearch -exact [string toupper $collist] [lindex $_listPreSelectedColNames $i]] !=-1 } {
lappend delColList [lindex $_listPreSelectedColNames $i]
} elseif { [lsearch -exact [string tolower $collist] [lindex $_listPreSelectedColNames $i]] !=-1 } {
lappend delColList [lindex $_listPreSelectedColNames $i]
} else {
lappend tmpList [lindex $_listPreSelectedColNames $i]
set _cellWidth($j) $_cellWidth($i)
incr j
}
}
}
for {} {$j < $_dispCols} {incr j} {
unset _cellWidth($j)
}
set _listPreSelectedColNames $tmpList
# update the _firstRow : updateFirst is a fitsTcl command
set _firstCol [updateFirst -c $_firstCol $_dispCols]
# delete row in the file
$fFile delCols $delColList
$fFile changeFile
# then update table info
# _updateNumCols
# refresh the table and children
refresh
_updateRestDisps
# reselect the cell
_selCell
_showselRows
}
itcl::body Table::_tryDelRows { {range 0} } {
if { $range !=0 } {
selRowsFromList $range 0 0
}
promptMsg \
"Table rows will be permanently deleted.\nAre you sure?" \
[itcl::code $this _delRowsRange] Yes No
# [itcl::code $this _delRows] Yes No
}
itcl::body Table::_tryDelCols {{collist -1}} {
promptMsg \
"Table columns will be permanently deleted.\nAre you sure?" \
[itcl::code $this _delCols $collist] Yes No
}
########################################################
#
# Row Selection
# Ziqin Pan, Jan 2004
#
itcl::body Table::_setRowStartMark {row} {
set _rstart [expr $_firstRow + $row ]
set _rend [expr $_firstRow + $row]
_selRows
_showselRows
}
itcl::body Table::_setRowEndMark {row} {
set _rend [expr $_firstRow + $row ]
_selRows
_showselRows
}
itcl::body Table::_unsetRowMark {} {
set _rstart ""
set _rend ""
}
itcl::body Table::_showselCheck {} {
set rowsel 0
for {set j 1} {$j <= $_numRows} {incr j} {
# set realRowNum [expr $_firstRow+$j]
if { ($_selectedRows($j) ==1) } {
set rowsel 1
break
}
}
if { $rowsel == 1} {
if {$_fth !=0 } {
$_fth turnsel 1
}
if {$_ftp !=0 } {
$_ftp turnsel 1
}
} else {
if {$_fth !=0 } {
$_fth turnsel 0
}
if {$_ftp !=0 } {
$_ftp turnsel 0
}
}
}
itcl::body Table::_showselRows {} {
set rowsel 0
for {set j 0} {$j < $_showRows} {incr j} {
set realRowNum [expr $_firstRow+$j]
if { ($_selectedRows($realRowNum) ==1) } {
$_droot.table.can.b$j configure -background yellow
set rowsel 1
} else {
$_droot.table.can.b$j configure -background $fvPref::globalBgColor
}
}
_showselCheck
}
itcl::body Table::_selInvert {} {
for {set j 0} {$j <= $_numRows} {incr j} {
if { ($_selectedRows($j) == 1)} {
set _selectedRows($j) 0
} else {
set _selectedRows($j) 1
}
}
_showselRows
}
itcl::body Table::_selAllRows {} {
if { ($_selectAllRows == 1 ) } {
for {set j 0} {$j <= $_numRows} {incr j} {
set _selectedRows($j) 1
}
} else {
for {set j 0} {$j <= $_numRows} {incr j} {
set _selectedRows($j) 0
}
}
_showselRows
}
itcl::body Table::_selRows {} {
if { $_rstart > $_rend } {
set tmp_rstart $_rend
set tmp_rend $_rstart
} else {
set tmp_rstart $_rstart
set tmp_rend $_rend
}
if { ($_rstart == "") || ($_rend =="") } {
return
} elseif { ($_rstart == $_rend)} {
if { ($_selectedRows($_rstart) == 0) } {
set _selectedRows($_rstart) 1
} else {
set _selectedRows($_rstart) 0
}
} else {
for {set i $tmp_rstart} { $i <= $tmp_rend} { incr i} {
if { ($_selectedRows($_rstart) == 0) } {
set _selectedRows($i) 0
} else {
set _selectedRows($i) 1
}
}
}
}
########################################################
#
# Cursor Motion Selection
#
itcl::body Table::_setEndMark {col row} {
_unselCell
#
if { $_oldcstartx == ""} return
if { $_oldcstarty == ""} return
set _cendx [expr $_firstCol + $col -1]
set _cendy [expr $_firstRow + $row -1]
if { $_cendx <= $_oldcstartx} {
set _cstartx $_cendx
set _cendx $_oldcstartx
} else {
set _cstartx $_oldcstartx
}
if { $_cendy <= $_oldcstarty} {
set _cstarty $_cendy
set _cendy $_oldcstarty
} else {
set _cstarty $_oldcstarty
}
_selCell
_showselRows
}
itcl::body Table::_unsetMark {} {
_unselCell
set _oldcstartx ""
set _oldcstarty ""
set _cstartx ""
set _cstarty ""
set _cendx ""
set _cendy ""
}
itcl::body Table::_setStartMark {col row {focus True}} {
_unsetMark
set _cstartx [expr $_firstCol + $col -1]
set _cstarty [expr $_firstRow + $row -1]
set _oldcstartx $_cstartx
set _oldcstarty $_cstarty
_copyCell $col $row
if { $focus } {
focus $_droot.table.can
}
}
itcl::body Table::_copyCell {col_ row_} {
_unselCell
set _currentCol [expr $_firstCol+ $col_ -1]
set _currentRow [expr $_firstRow+ $row_ -1]
if { $_currentCol<0 } {
set _currentCol 0
} elseif { $_currentCol >= $_dispCols } {
set _currentCol [expr $_dispCols-1]
}
if { $_currentRow<0 } {
set _currentRow 0
} elseif { $_currentRow >= $_numRows } {
set _currentRow [expr $_numRows-1]
}
_selCell
_showselRows
}
itcl::body Table::_unselCell {} {
# individual cell
if { [info exist _currentCol] } {
set tmpCol [expr $_currentCol - $_firstCol+1]
set tmpRow [expr $_currentRow - $_firstRow+1]
if { ($tmpCol >= $_showCols) || ($tmpCol < 0) || ($tmpRow >= $_showRows) \
|| ($tmpRow < 0) } {
;
} else {
set id ${tmpCol}_$tmpRow
$_droot.table.can.e$id configure -disabledbackground $fvPref::globalBgColor
set _cellVar ""
}
}
# a block of table
for {set i 0} { $i < $_showCols} { incr i} {
for {set j 0} { $j < $_showRows} { incr j} {
set id ${i}_$j
$_droot.table.can.e$id configure -disabledbackground $fvPref::globalBgColor
}
}
}
itcl::body Table::_selCell {} {
#puts "_selCell start"
if { [info exist _currentCol] } {
set tmpCol [expr $_currentCol - $_firstCol+1]
set tmpRow [expr $_currentRow - $_firstRow+1]
if { ($tmpCol >= $_showCols) || ($tmpCol < 0) || \
($tmpRow >= $_showRows) || ($tmpRow < 0) } {
$_droot.usrEntry.sel_e config -state disabled
} else {
$_droot.usrEntry.sel_e config -state normal
set id ${tmpCol}_$tmpRow
$_droot.table.can.e$id configure -disabledbackground yellow
set _cellVar [_getRawData $_currentCol $_currentRow]
$_droot.usrEntry.sel_e selection range 0 end
}
}
# a block of table
if { ($_cstartx == "") || ($_cstarty == "") || ($_cendx == "") \
|| ($_cendy == "") } {
return
} else {
for {set i 0} {$i< $_showCols} {incr i} {
set tmpCol [expr $_firstCol +$i -1]
if { ($tmpCol >= $_cstartx) && ($tmpCol<=$_cendx) } {
for {set j 0} { $j < $_showRows} { incr j} {
set tmpRow [expr $_firstRow+$j-1]
if { ($tmpRow >= $_cstarty) && ($tmpRow<=$_cendy) } {
set id ${i}_$j
$_droot.table.can.e$id configure -disabledbackground green
}
}
}
}
}
}
itcl::body Table::_cellUp {} {
# if no cell is selected do nothing.
if { [info exist _currentRow] == 0} return
# if up to the first row do nothing.
if { $_currentRow <= 0 } return
# if the current row is on the last page scroll up
if { $_currentRow < $_firstRow} {
incr _firstRow -1
refresh 0
}
#
set tmpCol [expr $_currentCol - $_firstCol+1]
set tmpRow [expr $_currentRow - $_firstRow+1]
_scrollChildren $_firstRow [expr $_currentRow-1]
_setStartMark $tmpCol [expr $tmpRow-1]
}
itcl::body Table::_cellDown {} {
# if no cell selected, do nothing
if { [info exist _currentRow] == 0} return
# if down to the last row, do nothing
if { $_currentRow > $_numRows } return
if { $_currentRow >= [expr $_firstRow + $_showRows -2]} {
incr _firstRow
refresh 0
}
set tmpCol [expr $_currentCol - $_firstCol+1]
set tmpRow [expr $_currentRow - $_firstRow+1]
_scrollChildren $_firstRow [expr $_currentRow+1]
_setStartMark $tmpCol [expr $tmpRow+1]
}
itcl::body Table::_pageUp {} {
_unselCell
if { [expr $_firstRow - $_showRows +1 ] < 1} {
set _firstRow 1
} else {
set _firstRow [expr $_firstRow - $_showRows + 1 ]
}
refresh 0
_selCell
_showselRows
_scrollChildren $_firstRow $_currentRow
}
itcl::body Table::_pageDown {} {
_unselCell
if { [expr $_firstRow + $_showRows -1] > [expr $_numRows - $_showRows +1]} {
set _firstRow [expr $_numRows - $_showRows +1]
} else {
set _firstRow [expr $_firstRow + $_showRows -1]
}
refresh 0
_selCell
_showselRows
_scrollChildren $_firstRow $_currentRow
}
itcl::body Table::_jumpTo { colName } {
set colIdx 0
if { $colName != "0" && $colName != "end" } {
set colIdx [lsearch -exact $_listPreSelectedColNames $colName]
}
if { $colName == "end" } {
set colIdx [expr [llength $_listPreSelectedColNames] - 1 ]
}
_setHScroll $colIdx
}
itcl::body Table::_cellLeft {} {
# if no cell is selected do nothing.
if { [info exist _currentCol] == 0} return
# if left to the first row do nothing.
if { $_currentCol <= 0 } return
# real move
if { $_currentCol < $_firstCol } {
_setHScroll [expr $_firstCol -2]
}
#
set tmpCol [expr $_currentCol - $_firstCol+1]
set tmpRow [expr $_currentRow - $_firstRow+1]
_setStartMark [expr $tmpCol-1] $tmpRow
}
itcl::body Table::_cellRight {} {
# if no cell is selected do nothing.
if { [info exist _currentCol] == 0} return
# if right to the last row do nothing.
if { $_currentCol > $_dispCols } return
# real move
while { $_currentCol >= [expr $_firstCol+$_showCols-2] \
&& [expr $_firstCol+$_showCols]<=$_dispCols } {
_setHScroll $_firstCol
}
#
set tmpCol [expr $_currentCol - $_firstCol+1]
set tmpRow [expr $_currentRow - $_firstRow+1]
_setStartMark [expr $tmpCol+1] $tmpRow
}
itcl::body Table::_editCell {} {
if { [$_droot.usrEntry.sel_e cget -state]=="disabled" } return
if { $_cellVar=="" } {
# Reset value
_selCell
} else {
_modifyTableCell $_currentCol $_currentRow $_cellVar
}
focus $_droot.table.can
$_droot.usrEntry.sel_e selection range 0 end
}
#
# End Cursor Motion Selection
#
###########################################################
itcl::body Table::getFatherFitsExtension {} {
return $_fatherFitsExtension
}
# called by VectorTable to get details of the column that gave birth to the
# VectorTable
itcl::body Table::getColumnInfo {name_ index_} {
return [set ${name_}($index_)]
}
itcl::body Table::_calculateCmd {} {
set cal ".cal_[namespace tail $this]"
if { [winfo exist $cal] == 1 } {
raise $cal
return
}
set calList [getCalcCols]
FitsCalculator $cal $this $calList
$cal configure -title "fv: Calculator"
}
itcl::body Table::getCalcCols {} {
# pick out the variable-length and zero-lngth vector columns from the calculator
set calList {}
for {set i 0} {$i < $_dispCols} {incr i} {
if { $_columnVecSize($i) > 0 } {
lappend calList [lindex $_listPreSelectedColNames $i]
}
}
return $calList
}
itcl::body Table::calculateCols {colname_ colform_ formula_ calselonly_} {
if { $calselonly_ == 0 } {
set selrange "1-$_numRows"
set result [catch {set isNew \
[$fFile addColumnFrExpr $colname_ $colform_ $formula_ $selrange] } err]
} else {
set selrange ""
set start_end "1-$_numRows"
append selrange [_parseToRowRange $start_end]
if { $selrange !="" } {
set fileID [open out w 0600]
close $fileID
set result [catch {set isNew \
[$fFile addColumnFrExpr $colname_ $colform_ $formula_ $selrange] } err]
} else {
set isNew 0
set result 0
}
}
if { $result == 1 } {
error "Calculation failed\n$err"
}
$fFile changeFile
if { $isNew == 1 } {
lappend _listPreSelectedColNames $colname_
}
_updateNumCols
_reframe
refresh
_updateRestDisps
}
itcl::body Table::_updateRestDisps {} {
# Update any other windows attached to this extension
$_fatherFitsExtension updateDisps $this
}
itcl::body Table::_sortCmd {} {
global g_titleFont
catch {destroy .fvsort}
powToplevel .fvsort .dummy
wm title .fvsort "fv: Sort"
_resetSKey
set [itcl::scope _isUniqMerge] 0
label .fvsort.label -text "Select column name for sorting" -font g_titleFont
label .fvsort.lbl -text "Columns" -font g_titleFont
listbox .fvsort.lb -yscrollcommand ".fvsort.sb set" -font g_titleFont
scrollbar .fvsort.sb -command ".fvsort.lb yview"
checkbutton .fvsort.fkeyc -variable [itcl::scope _psortcheck] \
-selectcolor $fvPref::checkBBgColor \
-font g_titleFont \
-activeforeground black -activebackground $fvPref::globalBgColor \
-width 0
checkbutton .fvsort.skeyc -variable [itcl::scope _ssortcheck] \
-selectcolor $fvPref::checkBBgColor \
-font g_titleFont \
-activeforeground black -activebackground $fvPref::globalBgColor \
-width 0
checkbutton .fvsort.tkeyc -variable [itcl::scope _tsortcheck] \
-selectcolor $fvPref::checkBBgColor \
-font g_titleFont \
-activeforeground black -activebackground $fvPref::globalBgColor \
-width 0
frame .fvsort.fsep -relief raised -borderwidth 2 -height 4
frame .fvsort.fsep1 -relief raised -borderwidth 2 -height 4
checkbutton .fvsort.merge -variable [itcl::scope _isUniqMerge] \
-selectcolor $fvPref::checkBBgColor -text No \
-font g_titleFont \
-activeforeground black -activebackground $fvPref::globalBgColor \
-width 0 -command [itcl::code $this _changeUniqLabel]
label .fvsort.mlabel -text "Delete multiple rows that have the same sort column values?" \
-font g_titleFont
button .fvsort.fkeyb -text "Primary Column" -command [itcl::code $this _getSortKey 1] -font g_titleFont
button .fvsort.skeyb -text "Second Column" -command [itcl::code $this _getSortKey 2] -font g_titleFont
button .fvsort.tkeyb -text "Third Column" -command [itcl::code $this _getSortKey 3] -font g_titleFont
entry .fvsort.fkeye -textvariable [itcl::scope _psortkey] -font g_titleFont
entry .fvsort.skeye -textvariable [itcl::scope _ssortkey] -font g_titleFont
entry .fvsort.tkeye -textvariable [itcl::scope _tsortkey] -font g_titleFont
label .fvsort.ascend -text "Ascending ?" -font g_titleFont
label .fvsort.help -text "Select Column(s) for sorting" -font g_titleFont
iwidgets::buttonbox .fvsort.bb
.fvsort.bb add sort -text "Sort" -command [itcl::code $this _sortColumn] -font g_titleFont
.fvsort.bb add clear -text "Clear" -command [itcl::code $this _resetSKey] -font g_titleFont
.fvsort.bb add cancel -text "Close" -command "destroy .fvsort" -font g_titleFont
.fvsort.bb add help -text "Help" -command "hhelp sortColumn" -font g_titleFont
foreach i $_listPreSelectedColNames {
.fvsort.lb insert end $i
}
grid configure .fvsort.lbl -column 0 -row 0 -sticky "snew"
grid configure .fvsort.lb -column 0 -row 1 -sticky "snew" -rowspan 7
grid configure .fvsort.sb -column 1 -row 1 -sticky "snew" -rowspan 7
grid configure .fvsort.ascend -column 2 -row 0 -sticky "snew"
grid configure .fvsort.help -column 3 -row 0 -sticky "snew" -columnspan 2
grid configure .fvsort.fkeyc -column 2 -row 1 -sticky "snew"
grid configure .fvsort.fkeyb -column 3 -row 1 -sticky "snew"
grid configure .fvsort.fkeye -column 4 -row 1 -sticky "snew"
grid configure .fvsort.skeyc -column 2 -row 2 -sticky "snew"
grid configure .fvsort.skeyb -column 3 -row 2 -sticky "snew"
grid configure .fvsort.skeye -column 4 -row 2 -sticky "snew"
grid configure .fvsort.tkeyc -column 2 -row 3 -sticky "snew"
grid configure .fvsort.tkeyb -column 3 -row 3 -sticky "snew"
grid configure .fvsort.tkeye -column 4 -row 3 -sticky "snew"
grid configure .fvsort.fsep -column 2 -row 4 -sticky "ew" \
-columnspan 3
grid configure .fvsort.merge -column 2 -row 5 -sticky "snew"
grid configure .fvsort.mlabel -column 3 -row 5 -columnspan 2 \
-sticky "w"
grid configure .fvsort.fsep1 -column 2 -row 6 -sticky "ew" \
-columnspan 3
grid configure .fvsort.bb -column 2 -row 7 -sticky "snew" -columnspan 3
}
itcl::body Table::_resetSKey {} {
set _psortkey ""
set _ssortkey ""
set _tsortkey ""
set _psortcheck 1
set _ssortcheck 1
set _tsortcheck 1
}
itcl::body Table::_getSortKey {key_} {
if { [catch {set curSel [lindex $_listPreSelectedColNames [.fvsort.lb curselection]]} \
err] == 1 } {
error "Please Select a column name from left-hand window first"
return
}
switch $key_ {
1 {
set _psortkey $curSel
}
2 {
set _ssortkey $curSel
}
3 {
set _tsortkey $curSel
}
default {
error "Unknown key"
return
}
}
}
itcl::body Table::_sortColumn {} {
set sortkey ""
set sortcheck ""
if { $_psortkey == "" } {
error "You need to select at least the primary key for sorting"
return
} else {
lappend sortkey $_psortkey
lappend sortcheck $_psortcheck
}
if { $_ssortkey != ""} {
lappend sortkey $_ssortkey
lappend sortcheck $_ssortcheck
}
if { $_tsortkey != ""} {
lappend sortkey $_tsortkey
lappend sortcheck $_tsortcheck
}
doSort $sortkey $sortcheck $_isUniqMerge
destroy .fvsort
}
itcl::body Table::doSort { keys_ dirs_ unique_ } {
if { [catch {set rowlist [$fFile sort $keys_ $dirs_ $unique_ ]} err] } {
error "Sort failed: $err"
return
}
set rowlist [lindex $rowlist 0]
set rowlen [llength $rowlist]
for { set i 0 } { $i <$rowlen } { incr i} {
set j [lindex $rowlist $i]
set tmplist([expr $i +1]) $_selectedRows($j)
}
for { set i 1} { $i <=$rowlen } { incr i} {
set _selectedRows($i) $tmplist($i)
}
set sortRowResultList $rowlist
# _showselRows
$fFile changeFile
refresh
_updateRestDisps
}
itcl::body Table::_cpyToCB {} {
# if nothing is selected return
if { $_cstartx == "" } return
set colStart $_cstartx
if { $_cendx=="" } {
set colEnd $_cstartx
} else {
set colEnd $_cendx
}
set rowStart $_cstarty
if { $_cendy=="" } {
set rowEnd $rowStart
} else {
set rowEnd $_cendy
}
set clipType "table"
set dx [expr $colEnd-$colStart+1]
set dy [expr $rowEnd-$rowStart+1]
set dataList [_getRawDataBlock $colStart $rowStart $colEnd $rowEnd]
fvClipBoard register $clipType $fileName "${dx}x${dy}" $dataList
}
itcl::body Table::_cpyFrCB {} {
# make sure the insert point is present
if { [info exist _currentCol] == 0} {
error "Please highlight the insert point"
return
}
# get info from the clipboard
if { [fvClipBoard hasRec] } {
set cbinfo [fvClipBoard report]
set clipType [lindex $cbinfo 0]
set clipData [lindex $cbinfo 2]
if { $clipType == "table" } {
$fFile changeFile
# Clip to Table size
set nCols [llength $clipData]
if { [expr $nCols+$_currentCol] > $_numCols } {
set clipData [lrange $clipData 0 [expr $_numCols-$_currentCol-1] ]
}
set nRows [llength [lindex $clipData 0]]
if { [expr $nRows+$_currentRow] > $_numRows } {
set lRow [expr $_numRows-$_currentRow-1]
set newData {}
foreach c $clipData {
lappend newData [lrange $c 0 $lRow]
}
set clipData $newData
}
_putRawDataBlock $_currentCol $_currentRow $clipData
} else {
error "The clipboard currently contains \"$clipType\" data. Cannot\
paste this into a table."
}
}
refresh
}
itcl::body Table::_changeUniqLabel {} {
if { $_isUniqMerge == 1} {
.fvsort.merge configure -text Yes
} else {
.fvsort.merge configure -text No
}
}
itcl::body Table::_statCmd {} {
global g_titleFont
catch {destroy .fvstat}
powToplevel .fvstat .dummy
wm title .fvstat "fv: Column Statistics"
label .fvstat.lbl -text "Select column:" -font g_titleFont
listbox .fvstat.lb -yscrollcommand ".fvstat.sb set" -font g_titleFont
scrollbar .fvstat.sb -command ".fvstat.lb yview"
foreach i $_listPreSelectedColNames {
.fvstat.lb insert end $i
}
bind .fvstat.lb <Double-Button-1> [itcl::code $this _statSelCmd]
bind .fvstat.lb <ButtonRelease-1> [itcl::code $this _statSelCmd]
label .fvstat.namel -text "Column Name" -font g_titleFont
label .fvstat.numl -text "Number of values" -font g_titleFont
label .fvstat.minl -text "Min" -font g_titleFont
label .fvstat.maxl -text "Max" -font g_titleFont
label .fvstat.meanl -text "Mean" -font g_titleFont
label .fvstat.fminl -text "First minimum in row" -font g_titleFont
label .fvstat.fmaxl -text "First maximum in row" -font g_titleFont
label .fvstat.stdl -text "Standard deviation" -font g_titleFont
label .fvstat.rowrangel -text "Row range" -font g_titleFont
checkbutton .fvstat.selonly -text "Use selected rows" \
-font g_titleFont \
-variable [itcl::scope _statselonly ] \
-selectcolor $fvPref::checkBBgColor \
-activeforeground black -activebackground $fvPref::globalBgColor \
-command [itcl::code $this _statSelCmd]
set [itcl::scope _colSName($this)] ""
set [itcl::scope _colNumVal($this)] ""
set [itcl::scope _colMin($this)] ""
set [itcl::scope _colMax($this)] ""
set [itcl::scope _colMean($this)] ""
set [itcl::scope _colFMin($this)] ""
set [itcl::scope _colFMax($this)] ""
set [itcl::scope _colStd($this)] ""
set _colRowRange($this) ""
entry .fvstat.namee -textvariable [itcl::scope _colSName($this)] \
-disabledforeground black \
-disabledbackground $fvPref::globalBgColor \
-relief raised -borderwidth 1 -stat disabled -font g_titleFont
entry .fvstat.nume -textvariable [itcl::scope _colNumVal($this)] \
-disabledforeground black \
-disabledbackground $fvPref::globalBgColor \
-relief raised -borderwidth 1 -stat disabled -font g_titleFont
entry .fvstat.mine -textvariable [itcl::scope _colMin($this)] \
-disabledforeground black \
-disabledbackground $fvPref::globalBgColor \
-relief raised -borderwidth 1 -stat disabled -font g_titleFont
entry .fvstat.maxe -textvariable [itcl::scope _colMax($this)] \
-disabledforeground black \
-disabledbackground $fvPref::globalBgColor \
-relief raised -borderwidth 1 -stat disabled -font g_titleFont
entry .fvstat.meane -textvariable [itcl::scope _colMean($this)] \
-disabledforeground black \
-disabledbackground $fvPref::globalBgColor \
-relief raised -borderwidth 1 -stat disabled -font g_titleFont
entry .fvstat.fmine -textvariable [itcl::scope _colFMin($this)] \
-disabledforeground black \
-disabledbackground $fvPref::globalBgColor \
-relief raised -borderwidth 1 -stat disabled -font g_titleFont
entry .fvstat.fmaxe -textvariable [itcl::scope _colFMax($this)] \
-disabledforeground black \
-disabledbackground $fvPref::globalBgColor \
-relief raised -borderwidth 1 -stat disabled -font g_titleFont
entry .fvstat.stde -textvariable [itcl::scope _colStd($this)] \
-disabledforeground black \
-disabledbackground $fvPref::globalBgColor \
-relief raised -borderwidth 1 -stat disabled -font g_titleFont
entry .fvstat.rowrange -textvariable [itcl::scope _colRowRange($this)] -font g_titleFont
bind .fvstat.rowrange <Return> +[itcl::code $this _statSelCmd]
button .fvstat.ok -text Close -command "destroy .fvstat" -font g_titleFont
button .fvstat.help -text Help -command "hhelp columnStatistics" -font g_titleFont
grid configure .fvstat.lbl -column 0 -row 0 -columnspan 2 \
-sticky "snew"
grid configure .fvstat.lb -column 0 -row 1 -rowspan 10 \
-sticky "snew"
grid configure .fvstat.sb -column 1 -row 1 -rowspan 10 \
-sticky "snw"
#add by ziqin pan
grid configure .fvstat.namel -column 2 -row 0 \
-sticky "snw"
grid configure .fvstat.numl -column 2 -row 1 \
-sticky "snw"
grid configure .fvstat.minl -column 2 -row 2 \
-sticky "snw"
grid configure .fvstat.maxl -column 2 -row 3 \
-sticky "snw"
grid configure .fvstat.meanl -column 2 -row 4 \
-sticky "snw"
grid configure .fvstat.fminl -column 2 -row 5 \
-sticky "snw"
grid configure .fvstat.fmaxl -column 2 -row 6 \
-sticky "snw"
grid configure .fvstat.stdl -column 2 -row 7 \
-sticky "snw"
grid configure .fvstat.rowrangel -column 2 -row 8 \
-sticky "snw"
grid configure .fvstat.namee -column 3 -row 0 \
-sticky "snew"
grid configure .fvstat.nume -column 3 -row 1 \
-sticky "snew"
grid configure .fvstat.mine -column 3 -row 2 \
-sticky "snew"
grid configure .fvstat.maxe -column 3 -row 3 \
-sticky "snew"
grid configure .fvstat.meane -column 3 -row 4 \
-sticky "snew"
grid configure .fvstat.fmine -column 3 -row 5 \
-sticky "snew"
grid configure .fvstat.fmaxe -column 3 -row 6 \
-sticky "snew"
grid configure .fvstat.stde -column 3 -row 7 \
-sticky "snew"
grid configure .fvstat.rowrange -column 3 -row 8 \
-sticky "snew"
#add by Ziqin Pan, Feb 18, 2004
grid configure .fvstat.selonly -column 2 -row 9 \
-sticky "snew" -columnspan 2 -pady 10
#
grid configure .fvstat.ok -column 2 -row 10 \
-sticky "s"
grid configure .fvstat.help -column 3 -row 10 \
-sticky "s"
}
#Add by Ziqin Pan, Jan, 2004
itcl::body Table::_parseToRowRange {start_end} {
set tmplist [split $start_end "-"]
set tmplistlen [llength $tmplist]
if {$tmplistlen <1 } {
set start 1
set end $_numRows
} elseif { $tmplistlen ==1} {
set start [lindex $tmplist 0]
set end $start
} else {
set start [lindex $tmplist 0]
set end [lindex $tmplist 1]
}
if { $start < 1 } {
set start 1
}
if { $end < 1 } {
set end 1
}
if { $start > $_numRows } {
set start $_numRows
}
if { $end > $_numRows } {
set end $_numRows
}
set selrange ""
for {set i $start} { $i <= $end} {incr i} {
if { $_selectedRows($i) == 1} {
for {set j $i} { $j <= $end} {incr j} {
if { $_selectedRows($j) == 0} {
break
}
}
if { $selrange =="" } {
append selrange $i "-" [expr $j - 1]
} else {
append selrange "," $i "-" [expr $j - 1]
}
set i $j
}
}
return $selrange
}
itcl::body Table::_statSelCmd {} {
set tmpindex [.fvstat.lb curselection]
if {$tmpindex == "" } return
set tmpName [.fvstat.lb get $tmpindex]
# set _colRowRange($this) [string trim $_colRowRange($this) " " ]
if { $_colRowRange($this) == "" } {
set tmprange "1-$_numRows"
} else {
# set tmprange [split $_colRowRange($this) ","]
set tmprange $_colRowRange($this)
}
if { $_statselonly == 0 } {
set paramList [$fFile getColStat $tmpName 1 $tmprange]
} else {
set selrange ""
set tmplist [split $tmprange ","]
set numlist [llength $tmplist]
for { set k 0 } {$k <$numlist } {incr k} {
set start_end [lindex $tmplist $k]
if { $selrange =="" } {
append selrange [_parseToRowRange $start_end]
} else {
append selrange "," [_parseToRowRange $start_end]
}
}
if { $selrange == "" } {
set paramList {"" "" "" "" "" "" 0}
} else {
set paramList [$fFile getColStat $tmpName 1 $selrange]
}
}
.fvstat.namee configure -state normal
.fvstat.mine configure -state normal
.fvstat.maxe configure -state normal
.fvstat.meane configure -state normal
.fvstat.fmine configure -state normal
.fvstat.fmaxe configure -state normal
.fvstat.stde configure -state normal
set [itcl::scope _colSName($this)] $tmpName
set [itcl::scope _colMin($this)] [lindex $paramList 0]
set [itcl::scope _colFMin($this)] [lindex $paramList 1]
set [itcl::scope _colMax($this)] [lindex $paramList 2]
set [itcl::scope _colFMax($this)] [lindex $paramList 3]
set [itcl::scope _colMean($this)] [lindex $paramList 4]
set [itcl::scope _colStd($this)] [lindex $paramList 5]
set [itcl::scope _colNumVal($this)] [lindex $paramList 6]
.fvstat.namee configure -state disabled
.fvstat.mine configure -state disabled
.fvstat.maxe configure -state disabled
.fvstat.meane configure -state disabled
.fvstat.fmine configure -state disabled
.fvstat.fmaxe configure -state disabled
.fvstat.stde configure -state disabled
}
# column of string can be left or right justified.
itcl::body Table::_makeJustification {} {
for {set i 0} {$i < $_showCols} {incr i} {
set tmpIndex [expr $_firstCol + $i -1]
if { [regexp A $_columnType($tmpIndex)] == 1} {
for {set j 0} { $j< $_showRows} {incr j} {
set id ${i}_$j
if { $fvPref::ifLeftJustifyString == 0} {
$_droot.table.can.e$id configure -justify right
} else {
$_droot.table.can.e$id configure -justify left
}
}
} else {
for {set j 0} { $j< $_showRows} {incr j} {
set id ${i}_$j
$_droot.table.can.e$id configure -justify right
}
}
}
}
itcl::body Table::bringToFront {} {
if { $_droot == "" || ![winfo exists $_droot] } {return 0}
if { ![winfo ismapped $_droot] } {
wm deiconify $_droot
}
raise $_droot
focus $_droot
return 1
}
itcl::body Table::_openVectorTable { colNum_ } {
set fV [VectorTable #auto $colNum_ $this]
$fV makeTable $_extNum
}
itcl::body Table::_ds9MakePlot1 { rowNum_ range xColumn_ yColumn_ {xeColumn_ ""} {yeColumn_ ""} {inCurrGraph_ 0}} {
global g_backupDir
global DS9plotName
#puts _ds9MakePlot1
#puts "_listPreSelectedColNames: $_listPreSelectedColNames"
#puts "xColumn_: $xColumn_"
#puts "yColumn_: $yColumn_"
set tmpfile ${g_backupDir}/ds9PlotTemp_[clock seconds].data
#puts "tmpfile: $tmpfile"
if [file exists $tmpfile] {
file delete -force $tmpfile
}
if { [catch {set newDataFile [open $tmpfile "w"]} err] } {
puts $err
error $err
return
}
# load the data with specific rowNum_ into the tmpfile
# set range "[expr $rowNum_ - 1]-[expr $rowNum_ - 1]"
#set range "$fRow-$lRow"
set col 0
set totalCol 2
set colIdx -1
set colIdxY -1
foreach name $_listPreSelectedColNames {
if { [string first $name $xColumn_] >= 0 } {
set searchX $name
set colIdx [lsearch $_listPreSelectedColNames $name]
break
}
}
foreach name $_listPreSelectedColNames {
if { [string first $name $yColumn_] >= 0 } {
set searchY $name
set colIdxY [lsearch $_listPreSelectedColNames $name]
break
}
}
set findXColumn true
if { $colIdx < 0 } {
set findXColumn false
}
set findYColumn true
if { $colIdxY < 0 } {
set findYColumn false
}
if { $findYColumn == "true" && $findXColumn == "false" } {
set colIdx $colIdxY
set xColumn_ $yColumn_
}
set key [$fFile getKeyword TFORM[expr $colIdx + 1]]
set value "[string trim [lindex [lindex $key 0] 1] {' ()}]"
#puts "value: $value"
# set value [string range $value 0 [expr [string length $value] - 2]]
regsub -all {[a-zA-Z]} $value {} value
#puts "after value: $value"
if { $value == "" } {
set value 1
}
# take care x error or y error
set errorIdxX -1
set errorIdxY -1
foreach name $_listPreSelectedColNames {
if { [string first $name $xeColumn_] >= 0 } {
set errorIdxX [lsearch $_listPreSelectedColNames $name]
break
}
}
foreach name $_listPreSelectedColNames {
if { [string first $name $yeColumn_] >= 0 } {
set errorIdxY [lsearch $_listPreSelectedColNames $name]
break
}
}
set findXerr true
if { $errorIdxX < 0 || $xeColumn_ ==""} {
set findXerr false
}
set findYerr true
if { $errorIdxY < 0 || $yeColumn_ ==""} {
set findYerr false
}
#puts "check value: $value, range: $range"
for { set col 1 } { $col <= $value } {incr col} {
set data [_getDataForAxis "x" $xColumn_ $range]
set tokens [ptr2lst [lindex $data 0] [lindex $data 1] [lindex $data 2]]
#puts "tokens: $tokens"
if { $colIdxY >= 0 } {
set data2 [_getDataForAxis "y" $yColumn_ $range]
set tokens2 [ptr2lst [lindex $data2 0] [lindex $data2 1] [lindex $data2 2]]
}
#puts "tokens2: $tokens2"
if { $errorIdxX >=0 } {
set errData [_getDataForAxis "xe" $xeColumn_ $range]
set errTokens [ptr2lst [lindex $errData 0] [lindex $errData 1] [lindex $errData 2]]
}
if { $errorIdxY >=0 } {
set errData2 [_getDataForAxis "ye" $yeColumn_ $range]
set errTokens2 [ptr2lst [lindex $errData2 0] [lindex $errData2 1] [lindex $errData2 2]]
}
set monoflag 1
for { set i 0 } { $i < [llength $tokens] } {incr i} {
if { $findXColumn == "true" && $findYColumn == "true" } {
set finalStr [format "%s %s" [lindex $tokens $i] [lindex $tokens2 $i]]
} elseif { $xColumn_ == "RowNumber" } {
set finalStr [format "%s %s" [expr $i + 1] [lindex $tokens $i]]
} elseif { $yColumn_ == "RowNumber" } {
set finalStr [format "%s %s" [lindex $tokens $i] [expr $i + 1]]
} else {
if { $findXColumn == "false" } {
set finalStr [format "%s %s" $col [lindex $tokens $i]]
} else {
set finalStr [format "%s %s" [lindex $tokens $i] $col]
}
}
if { $findXerr } {
set finalStr [format "%s %s" $finalStr [lindex $errTokens $i] ]
}
if { $findYerr } {
set finalStr [format "%s %s" $finalStr [lindex $errTokens2 $i] ]
}
set finalTokens [split $finalStr " "]
if { $monoflag == 1 } {
if { $i ==0 } {
set xval [lindex $finalTokens 0]
} elseif { $i == 1} {
set xval2 [lindex $finalTokens 0]
} else {
set xval3 [lindex $finalTokens 0]
if { $xval <= $xval2 && $xval2 <= $xval3 } {
} elseif { $xval >= $xval2 && $xval2 >= $xval3 } {
} else {
set monoflag 0
}
#puts "1:$xval, 2:$xval2, 3:$xval3, mono:$monoflag"
set xval $xval2
set xval2 $xval3
}
}
puts $newDataFile $finalStr
}
}
close $newDataFile
set err "none"
catch {exec xpaaccess ds9} result
#puts "result: $result"
if { [string range $result 0 1] == "no" } {
# start DS9 if DS9 isn't there
if { [catch {exec ds9 &} ds9pid] } {
file delete $tmpfile
if { [tk_dialog .saoError "DS9 startup error.. Cannot start DS9!\nUse POW instead?" \
question 0 Yes No] == 0 } {
close $fFile
return NO_YET
}
close $fFile
return DONE
}
# wait till ds9 is up
set flag 1
set nSecs 0
while { $flag } {
after 1000
incr nSecs
catch {exec xpaaccess ds9} result
if { [string range $result 0 2] == "yes" } {
set flag 0
} else {
if { $nSecs > 10 } {
file delete $tmpfile
if { [tk_dialog .saoError "DS9 startup error.. Cannot start ds9!\nUse POW instead?" \
question 0 Yes No] == 0 } {
close $fFile
return NO_YET
}
close $fFile
return DONE
}
}
}
}
if { $rowNum_ == "NONE" } {
set displayName [file tail $fileName]
} else {
set displayName [format "%s\(%s\)" [file tail $fileName] [expr $rowNum_ + 1]]
}
#puts "ready to call DS9"
#puts "displayName: $displayName"
if {$inCurrGraph_ == 1} {
set ds9plotList {}
catch {exec xpaget ds9 plot} result
set ds9plotList [split $result " "]
#puts "ds9plotList: $ds9plotList"
if ![info exists DS9plotName] {
set inCurrGraph_ 0
} else {
#puts "DS9plotName: $DS9plotName"
if { [lsearch -exact $ds9plotList $DS9plotName] < 0 } {
set inCurrGraph_ 0
} else {
if { $findXerr && $findYerr } {
exec xpaset ds9 plot $DS9plotName data xyexey < $tmpfile
} elseif { $findXerr } {
exec xpaset ds9 plot $DS9plotName data xyex < $tmpfile
} elseif { $findYerr } {
exec xpaset ds9 plot $DS9plotName data xyey < $tmpfile
} else {
exec xpaset ds9 plot $DS9plotName data xy < $tmpfile
}
}
}
}
if {$inCurrGraph_ == 0} {
set DS9plotName ds9plot_[clock seconds]
#puts "ready to print"
if { $findXerr && $findYerr } {
exec xpaset ds9 plot new name $DS9plotName $displayName $xColumn_ $yColumn_ xyexey < $tmpfile
} elseif { $findXerr } {
exec xpaset ds9 plot new name $DS9plotName $displayName $xColumn_ $yColumn_ xyex < $tmpfile
} elseif { $findYerr } {
exec xpaset ds9 plot new name $DS9plotName $displayName $xColumn_ $yColumn_ xyey < $tmpfile
} else {
exec xpaset ds9 plot new name $DS9plotName $displayName $xColumn_ $yColumn_ xy < $tmpfile
}
}
if { $monoflag == 0 } {
exec xpaset -p ds9 plot line discrete diamond
exec xpaset -p ds9 plot view line no
exec xpaset -p ds9 plot view discrete yes
} else {
exec xpaset -p ds9 plot view line yes
exec xpaset -p ds9 plot view discrete no
}
# if { $totalCol > 2 } {
# exec xpaset ds9 analysis plot $displayName $xColumn_ $yColumn_ \
# $totalCol < $tmpfile
# } else {
# exec xpaset ds9 analysis plot $displayName $xColumn_ $yColumn_ 2 < $tmpfile
# }
# file delete $tmpfile
return DONE
}
itcl::body Table::_ds9MakePlot { rowNum_ fRow lRow xColumn_ yColumn_ {xeColumn_ ""} {yeColumn_ ""} } {
global g_backupDir
global DS9plotName
#puts _ds9MakePlot
#puts "_listPreSelectedColNames: $_listPreSelectedColNames"
#puts "xColumn_: $xColumn_"
#puts "yColumn_: $yColumn_"
set tmpfile ${g_backupDir}/ds9PlotTemp.data
if [file exists $tmpfile] {
file delete -force $tmpfile
}
if { [catch {set newDataFile [open $tmpfile "w"]} err] } {
error $err
return
}
# load the data with specific rowNum_ into the tmpfile
# set range "[expr $rowNum_ - 1]-[expr $rowNum_ - 1]"
set range "$fRow-$lRow"
set col 0
set totalCol 2
set findXColumn true
set colIdx [lsearch $_listPreSelectedColNames $xColumn_]
#puts "colIdx: $colIdx"
if { $colIdx < 0 } {
set findXColumn false
}
set findYColumn true
set colIdxY [lsearch $_listPreSelectedColNames $yColumn_]
if { $colIdxY < 0 } {
set findYColumn false
}
if { $findYColumn == "true" && $findXColumn == "false" } {
set colIdx $colIdxY
}
set key [$fFile getKeyword TFORM[expr $colIdx + 1]]
set value "[string trim [lindex [lindex $key 0] 1] {' ()}]"
set value [string range $value 0 [expr [string length $value] - 2]]
if { $value == "" } {
set value 1
}
# take care x error or y error
if { $xeColumn_ != "" || $yeColumn_ != "" } {
if { $xeColumn_ != "" } {
set errorIdx [lsearch $_listPreSelectedColNames $xeColumn_]
set thirdCol $xeColumn_
} else {
set errorIdx [lsearch $_listPreSelectedColNames $yeColumn_]
set thirdCol $yeColumn_
}
incr totalCol
}
#puts "value: $value"
for { set col 1 } { $col <= $value } {incr col} {
set data [$fFile getVectorTableAsRawList [lindex $_listPreSelectedColNames $colIdx] $col $range]
set tokens [split $data " "]
if { $colIdxY >= 0 } {
set data2 [$fFile getVectorTableAsRawList [lindex $_listPreSelectedColNames $colIdxY] $col $range]
set tokens2 [split $data2 " "]
}
if { $xeColumn_ != "" || $yeColumn_ != "" } {
if { $errorIdx >= 0 } {
set errRata [$fFile getVectorTableAsRawList [lindex $_listPreSelectedColNames $errorIdx] $col $range]
set errTokens [split $errData " "]
}
}
for { set i 0 } { $i < [llength $tokens] } {incr i} {
if { $findXColumn == "true" && $findYColumn == "true" } {
set finalStr [format "%s %s" [lindex $tokens $i] [lindex $tokens2 $i]]
} elseif { $xColumn_ == "RowNumber" } {
set finalStr [format "%s %s" [expr $i + 1] [lindex $tokens $i]]
} elseif { $yColumn_ == "RowNumber" } {
set finalStr [format "%s %s" [lindex $tokens $i] [expr $i + 1]]
} else {
if { $findXColumn == "false" } {
set finalStr [format "%s %s" $col [lindex $tokens $i]]
} else {
set finalStr [format "%s %s" [lindex $tokens $i] $col]
}
}
if { $xeColumn_ != "" || $yeColumn_ != "" } {
if { $errorIdx >= 0 } {
set finalStr [format "%s %s" $finalStr [lindex $errTokens $i]]
} else {
if { $xeColumn_ == "RowNumber" || $yeColumn_ == "RowNumber"} {
set finalStr [format "%s %s" $finalStr [expr $i + 1]]
} else {
set finalStr [format "%s %s" $finalStr $col]
}
}
}
puts $newDataFile $finalStr
}
}
close $newDataFile
set err "none"
catch {exec xpaaccess ds9} result
if { [string range $result 0 1] == "no" } {
# start DS9 if DS9 isn't there
if { [catch {exec ds9 &} ds9pid] } {
file delete $tmpfile
if { [tk_dialog .saoError "DS9 startup error.. Cannot start DS9!\nUse POW instead?" \
question 0 Yes No] == 0 } {
close $fFile
return NO_YET
}
close $fFile
return DONE
}
# wait till ds9 is up
set flag 1
set nSecs 0
while { $flag } {
after 1000
incr nSecs
catch {exec xpaaccess ds9} result
if { [string range $result 0 2] == "yes" } {
set flag 0
} else {
if { $nSecs > 10 } {
file delete $tmpfile
if { [tk_dialog .saoError "DS9 startup error.. Cannot start ds9!\nUse POW instead?" \
question 0 Yes No] == 0 } {
close $fFile
return NO_YET
}
close $fFile
return DONE
}
}
}
}
if { $rowNum_ == "NONE" } {
set displayName [file tail $fileName]
} else {
set displayName [format "%s\(%s\)" [file tail $fileName] [expr $rowNum_ + 1]]
}
#puts "displayName: $displayName"
#puts "tmpfile: $tmpfile"
set DS9plotName ds9plot_[clock seconds]
# if { $totalCol > 2 } {
# exec xpaset ds9 plot new name $displayName $displayName $xColumn_ $yColumn_ \
# $thirdCol $totalCol < $tmpfile
# } else {
exec xpaset ds9 plot new name $DS9plotName $displayName $xColumn_ $yColumn_ xy < $tmpfile
# }
file delete $tmpfile
return DONE
}
itcl::body Table::_plotVectorTableRow { colIdx rowNum_ } {
if { $fvPref::imgDisplayer == "DS9" } {
# display is for DS9
set flag "NOT_YET"
# ds9 file start with 1 instead of 0
set rowNum_ [expr $_firstRow + $rowNum_ - 1]
set flag [_ds9MakePlot $rowNum_ [expr $rowNum_ + 1] [expr $rowNum_ + 1] \
ElementNumber [lindex $_listPreSelectedColNames $colIdx]]
if { $flag == "DONE" } return
}
# apparently, plot does not need to use sortlist after the row is sorted
set rowNum_ [expr $_firstRow + $rowNum_ ]
set selectCol [lindex $_listPreSelectedColNames $colIdx ]
_plotCols ElementNumber {} $selectCol {} 0 $rowNum_ 0
}
itcl::body Table::addChild { child_ } {
lappend _myChildren $child_
}
itcl::body Table::freeChild { child_ } {
set pos [lsearch $_myChildren $child_]
if { $pos != -1 } {
set _myChildren [lreplace $_myChildren $pos $pos]
}
}
itcl::body Table::passParamsToVectorTable {} {
return [list $_numRows $isFailedToCopy $fileName $currentHDU]
}
itcl::body Table::_scrollChildren { firstRow {currentRow -1} } {
set tmpRow $currentRow
if { ($tmpRow == -1) && [info exist _currentRow] } {
set tmpRow $_currentRow
}
# Check for locked children
foreach child $_myChildren {
catch {
if { [$child _isVScrollLocked] } {
$child _setVScroll [expr $firstRow-1]
#puts "firstrow=$firstRow tmpRow=$tmpRow"
# if { $tmpRow >= 0 } {
# $child _setStartMark 0 [expr $tmpRow-$firstRow+1] False
# }
}
}
}
}
itcl::body Table::_isVScrollLocked {} {
return $_isVScrollLocked1
}
|