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
|
/* File:colcontrol.c
* Author: Simon Kelley (srk@sanger.ac.uk)
* Copyright (C) J Thierry-Mieg and R Durbin, 1994
* -------------------------------------------------------------------
* Acedb is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
* or see the on-line version at http://www.gnu.org/copyleft/gpl.txt
* -------------------------------------------------------------------
* Acedb is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
* or see the on-line version at http://www.gnu.org/copyleft/gpl.txt
* -------------------------------------------------------------------
* This file is part of the ACEDB genome database package, written by
* Richard Durbin (MRC LMB, UK) rd@mrc-lmb.cam.ac.uk, and
* Jean Thierry-Mieg (CRBM du CNRS, France) mieg@kaa.cnrs-mop.fr
*
* Description: package for generic map drawing containing:
* columns cotrol
* zoom, middle button scroll, locator
* findScaleUnits
* multiple Map support
* column data abstraction
* Exported functions:
* HISTORY:
* Last edited: Jun 13 16:00 2007 (edgrif)
* * Oct 13 14:30 1998 (edgrif): Replaced ACEDB defines with function
* calls. Removed some acedb specific code to acedbgraph.c
* Created: Wed Mar 20 13:40:35 1992 (srk)
* CVS info: $Id: colcontrol.c,v 1.89 2007/06/19 11:17:55 edgrif Exp $
*-------------------------------------------------------------------
*/
#include <wh/regular.h>
#include <wh/aceio.h>
#include <w2/graph_.h>
#include <wh/colcontrol_.h>
/************************************************************/
magic_t GRAPH2COLCONTROL_ASSOC = "COLCONTROL";
magic_t GRAPH2COLCONTROL_LOCALS_ASSOC = "COLCONTROL_LOCALS";
static magic_t COLCONTROL_MAGIC = "COLCONTROL";
static magic_t MAPCONTROL_MAGIC = "MAPCONTROL";
/************************************************************/
static void controlDestroyed(void);
static void controlLeftDrag(double x, double y);
static void controlLeftUp(double x, double y);
static void controlPick(int box, double x, double y, int modifier_unused);
static void controlSelect(int box, double x, double y);
static void controlKybd(int k, int modifier_unused);
static void controlMiddleDrag(double x, double y);
static void controlMiddleUp(double x, double y);
static void controlMiddleDown(double x, double y);
/* Used to assign colours to maps */
static int colourOrder[] = { GREEN, YELLOW, CYAN, MAGENTA, LIGHTGRAY };
static COLOUROPT ColButton = { viewWindowCreate, 0, BLACK, WHITE, "Views...", 0 };
/************************************************************/
/* redo the configure routine to be non blocking and use RD's editor routines */
static void controlConfigOK(void)
{
COLINSTANCE instance;
void *locals;
if(graphCheckEditors(graphActive(),TRUE))
{
graphAssFind(&GRAPH2COLCONTROL_ASSOC, &instance);
graphAssFind(&GRAPH2COLCONTROL_LOCALS_ASSOC, &locals);
(*(instance->configFinal))(instance, locals, TRUE); /* FALSE in KO case */
instance->configGraph = 0;
graphDestroy();
controlDrawControl(instance->map->control);
}
} /* controlConfigOK */
static void controlConfigKO(void)
{
COLINSTANCE instance;
void *locals;
if(!graphAssFind(&GRAPH2COLCONTROL_ASSOC, &instance))
printf("Could not find instance associated with GRAPH2COLCONTROL_ASSOC\n");
if(!graphAssFind(&GRAPH2COLCONTROL_LOCALS_ASSOC, &locals))
printf("Could not find locals associated with GRAPH2COLCONTROL_LOCALS_ASSOC\n");
(*(instance->configFinal))(instance, locals, FALSE); /* FALSE in KO case */
instance->configGraph = 0;
graphDestroy();
} /* controlConfigKO */
static void controlConfigApply(void)
{
COLINSTANCE instance;
void *locals;
if(!graphAssFind(&GRAPH2COLCONTROL_ASSOC, &instance))
printf("Could not find instance associated with GRAPH2COLCONTROL_ASSOC\n");
if(!graphAssFind(&GRAPH2COLCONTROL_LOCALS_ASSOC, &locals))
printf("Could not find locals associated with GRAPH2COLCONTROL_LOCALS_ASSOC\n");
(*(instance->configFinal))(instance, locals, TRUE); /* FALSE in KO case */
controlDrawControl(instance->map->control);
/* instance->configGraph = 0;
graphDestroy();*/
} /* controlConfigApply */
Graph controlCreateConfig(COLINSTANCE instance, void *locals,char *text, float width, float height)
{
Graph g;
int width2,height2;
if (instance->configGraph)
{
graphActivate(instance->configGraph);
graphPop();
return 0;
}
g = graphCreate(TEXT_SCROLL,text,0.5,0.4, width, height);
instance->configGraph = g;
graphAssociate(&GRAPH2COLCONTROL_ASSOC, instance);
graphAssociate(&GRAPH2COLCONTROL_LOCALS_ASSOC, locals);
graphRegister(DESTROY,controlConfigKO);
graphFitBounds(&width2,&height2);
graphButton("Apply",controlConfigApply,(float)(width2/2.0)-7.0,height2 - 2.0);
graphButton("OK",controlConfigOK,(float)(width2/2.0),height2 - 2.0);
graphButton("Cancel",graphDestroy,(float)(width2/2.0)+4.0,height2 - 2.0);
return g;
}
/* There used to be on colControlCreate which had different function */
/* signatures and code according to whether it was compiled with ACEDB or */
/* not. I have now split this into two functions with some duplicated code */
/* which will be gradually be unified.... */
/* */
/* This is the form for ACEDB type code that is going to create its own */
/* display. */
/* */
/* NOTE that this routine is not going to work well unless the application */
/* has registered a displayCreate routine to set up the graph, the default */
/* action is to attempt to display something. */
/* */
COLCONTROL colControlCreate(BOOL isoldgraph, char *name, char *dispName)
{
int gw, gh;
STORE_HANDLE handle = handleCreate();
COLCONTROL control = (COLCONTROL)halloc(sizeof (struct ColControlStruct), handle);
if (isoldgraph)
{
controlDestroyed();
graphClear();
control->graph = graphActive();
}
else
{
/* ACEDB-GRAPH INTERFACE: if display function registered, call it, */
/* otherwise do our own, note that if no function is registered then an */
/* educated guess is made about window size. */
if (getGraphAcedbDisplayCreate() != NULL)
control->graph = (getGraphAcedbDisplayCreate())(dispName) ;
else
control->graph = graphCreate(TEXT_FIT, name, 0.5, 0.5, 0, 0);
if (!control->graph)
{
handleDestroy(handle);
return 0;
}
graphRegister(RESIZE, controlDraw);
graphRegister(DESTROY, controlDestroyed);
graphRegister(KEYBOARD, controlKybd);
graphRegister(PICK, controlPick);
graphRegister(MIDDLE_DOWN, controlMiddleDown);
}
graphRetitle(name); /* Different code */
graphAssociate(&GRAPH2COLCONTROL_ASSOC, control);
/* link this map to the window */
control->magic = &COLCONTROL_MAGIC ;
control->handle = handle;
control->instances = arrayHandleCreate (50, COLINSTANCE, handle);
control->boxIndex = arrayHandleCreate(100, COLINSTANCE, handle);
control->boxIndex2 = arrayHandleCreate(100, void *, handle);
control->maps = arrayHandleCreate (4, MAPCONTROL, handle) ;
control->mapTransitions = arrayHandleCreate(100, float, handle);
control->bottomBoxes = assHandleCreate(handle);
control->currentMap = 0;
control->activeBox = 0;
control->activeKey = 0; /* Different code */
control->activeInstance = 0;
control->viewWindow = 0;
control->hideHeader = FALSE;
graphFitBounds(&gw, &gh); /* returns ints */
control->graphWidth = gw; /* make floats */
control->graphHeight = gh;
return control ;
}
/* This routine is essentially the same as the one above with a few */
/* differences - labelled in the routine above. */
/* Only coltest.c uses this form of the call within the entire CVS_ACEDB*/
/* tree....if someone outside uses it they can simply change their call */
/* to colControlBasicCreate and all should work. */
/* */
COLCONTROL colControlBasicCreate(BOOL isoldgraph, int type, char *name,
float x, float y, float w, float h)
{
int gw, gh;
STORE_HANDLE handle = handleCreate();
COLCONTROL control = (COLCONTROL)halloc(sizeof (struct ColControlStruct), handle);
if (isoldgraph)
{
controlDestroyed();
graphClear();
control->graph = graphActive();
}
else
{
control->graph = graphCreate(type, name, x, y, w, h);
if (!control->graph)
{
handleDestroy(handle);
return 0;
}
graphRegister(RESIZE, controlDraw);
graphRegister(DESTROY, controlDestroyed);
graphRegister(KEYBOARD, controlKybd);
graphRegister(PICK, controlPick);
graphRegister(MIDDLE_DOWN, controlMiddleDown);
}
graphAssociate(&GRAPH2COLCONTROL_ASSOC, control);
/* link this map to the window */
control->magic = &COLCONTROL_MAGIC ;
control->handle = handle;
control->instances = arrayHandleCreate (50, COLINSTANCE, handle);
control->boxIndex = arrayHandleCreate(100, COLINSTANCE, handle);
control->boxIndex2 = arrayHandleCreate(100, void *, handle);
control->maps = arrayHandleCreate (4, MAPCONTROL, handle) ;
control->mapTransitions = arrayHandleCreate(100, float, handle);
control->bottomBoxes = assHandleCreate(handle);
control->currentMap = 0;
control->activeBox = 0;
control->activeInstance = 0;
control->viewWindow = 0;
control->hideHeader = FALSE;
graphFitBounds(&gw, &gh); /* returns ints */
control->graphWidth = gw; /* make floats */
control->graphHeight = gh;
return control;
}
/* Do the common parts of map creation. The caller must fill in lots more */
/* fields in the map structure before calling controlAddMap() */
/* */
MAPCONTROL mapControlCreate(COLCONTROL control, void (*finaliseFunc)(void *p))
{
STORE_HANDLE handle = handleHandleCreate(control->handle);
MAPCONTROL map;
map = (MAPCONTROL)halloc(sizeof(struct MapControlStruct), handle);
blockSetFinalise (map, finaliseFunc);
map->handle = handle;
map->magic = &MAPCONTROL_MAGIC;
map->name = ""; /* default */
map->menu = 0; /* default */
/* ACEDB-GRAPH INTERFACE: set acedb specific map field. */
if (getGraphAcedbResetKey() != NULL) (getGraphAcedbResetKey())(&(map->viewKey)) ;
map->beforeDraw = 0;
map->drawHeader = 0;
map->headerPick = 0;
map->convertTrans = 0;
map->keyboard = 0;
map->topMargin = 0;
map->permConversionRoutines = arrayHandleCreate(50,
struct ConversionRecord,
handle);
map->transConversionRoutines = arrayHandleCreate(50,
struct ConversionRecord,
handle);
map->buttons = 0;
map->buttonsAddHere = &map->buttons;
map->menusOnButtons = arrayHandleCreate(10, MENUOPT *, handle);
map->suppressed = FALSE;
map->submenus = FALSE;
map->cambridgeOptions = TRUE;
map->noButtons = FALSE;
map->cursor.unit = 1; /* allows calls to set cursor without a scale column */
return map;
}
COLCONTROL currentColControl(char *caller)
{
COLCONTROL control;
if (!(graphAssFind(&GRAPH2COLCONTROL_ASSOC, &control)))
messcrash("%s() could not find COLCONTROL on graph", caller);
if (!control)
messcrash("%s() received NULL COLCONTROL pointer", caller);
if (control->magic != &COLCONTROL_MAGIC)
messcrash("%s() received non-magic COLCONTROL pointer", caller);
return control;
} /* currentColControl */
MAPCONTROL currentMapControl(void)
{
MAPCONTROL map = currentColControl("currentMapControl")->currentMap;
char *caller = "currentMapControl";
if (!map)
messcrash("%s() received NULL MAPCONTROL pointer", caller);
if (map->magic != &MAPCONTROL_MAGIC)
messcrash("%s() received non-magic MAPCONTROL pointer", caller);
return map;
} /* currentMapControl */
void controlAddMap(COLCONTROL control, MAPCONTROL map)
{
COLPROTO proto, *protop;
int c,m,i;
/* find an unused Colour */
for (c=0; colourOrder[c] != LIGHTGRAY; c++)
{ for (m=0; m<arrayMax(control->maps); m++)
if (arr(control->maps, m, MAPCONTROL)->colour == colourOrder[c])
break;
if (m == arrayMax(control->maps))
break;
}
map->colour = colourOrder[c];
array(control->maps, arrayMax(control->maps), MAPCONTROL) = map;
map->control = control;
controlAddButton(map, &ColButton, 0);
/* the prototypes have map-private data fields, so we first make a private
copy of the prototypes, we put this in an array for easy access. */
/* we also put the key correponding to the name in both the original,
and copies, to match them again in conteolSetView and controlReadConfig */
map->protoArray = arrayHandleCreate(30, struct ProtoStruct, map->handle);
for (protop = map->prototypes; *protop; protop++)
{
/* ACEDB-GRAPH INTERFACE: If acedb is registered record the name and key */
/* of this map. */
if (getGraphAcedbAddMap() != NULL) (getGraphAcedbAddMap())((*protop)->name, &(*protop)->key) ;
array(map->protoArray, arrayMax(map->protoArray), struct ProtoStruct) = **protop;
}
for (i = 0; i<arrayMax(map->protoArray); i++)
{ proto = arrp(map->protoArray, i, struct ProtoStruct);
/* call init routines, if they have them. */
if (proto->init)
(*proto->init)(proto, map);
/* now register any permanent conversion routines */
if (proto->conRoutine)
{ struct ConversionRecord *c;
int i;
for(i=0; i<arrayMax(map->permConversionRoutines); i++)
{ c = arrp(map->permConversionRoutines, i,
struct ConversionRecord );
if (c->convertRoutine == proto->conRoutine &&
c->params == proto->convertParams)
goto done;
}
/* new one here */
c = arrayp(map->permConversionRoutines,
arrayMax(map->permConversionRoutines),
struct ConversionRecord);
c->convertRoutine = proto->conRoutine;
c->params = proto->convertParams;
done:
proto->convertResults = &c->results;
}
}
map->needConvert = TRUE;
if (!control->currentMap) /* first one */
control->currentMap = map ;
if (map->topMargin > control->realTopMargin)
control->realTopMargin = map->topMargin;
}
void controlReadConfig(MAPCONTROL map, COLDEFAULT colInit)
{
int i= 0;
while (colInit[i].proto)
{ int j;
COLPROTO proto;
COLINSTANCE instance = 0;
/* have a reference to the original proto array, find
correponding entry in the per-map copy */
for (j=0; j<arrayMax(map->protoArray); j++)
{ proto = arrp(map->protoArray, j, struct ProtoStruct);
if (proto->key == (colInit[i].proto)->key)
instance = controlInstanceCreate(proto,
map,
colInit[i].displayed,
0,
colInit[i].name);
}
if (instance)
array(map->control->instances,
arrayMax(map->control->instances),
COLINSTANCE) = instance ;
i++;
}
}
/* delete the instance from the map */
void controlDeleteInstance(COLCONTROL control, COLINSTANCE instance)
{
int i,j;
Graph old = graphActive();
if (control->activeInstance == instance)
{
control->activeInstance = 0;
/* ACEDB-GRAPH INTERFACE: reset acedb specific field. */
if (getGraphAcedbResetKey() != NULL) (getGraphAcedbResetKey())(&(control->activeKey)) ;
}
for (i=0,j=0; i<arrayMax(control->instances); i++)
{ COLINSTANCE instance1 = arr(control->instances, i, COLINSTANCE);
if (instance1 != instance)
arr(control->instances, j++, COLINSTANCE) = instance1;
}
arrayMax(control->instances) = j;
if(instance->configGraph &&
old != instance->configGraph)
{ /* remove configure menu if it exists */
graphActivate(instance->configGraph);
graphDestroy();
graphActivate(old);
}
handleDestroy(instance->handle);
}
/* delete a map from the display, if it's the last, destroy the window. */
void controlDeleteMap(COLCONTROL control, MAPCONTROL map)
{ int i, j;
if (arrayMax(control->maps) == 1)
{ controlDestroy(control);
return;
}
for (i=0; i<arrayMax(control->instances); i++)
{ COLINSTANCE instance = arr(control->instances, i, COLINSTANCE);
if (instance->map == map)
{ controlDeleteInstance(control, instance);
i--; /* above deletes one */
}
}
for (i=0, j=0; i<arrayMax(control->maps); i++)
{ MAPCONTROL map1 = arr(control->maps, i, MAPCONTROL);
if (map1 != map)
arr(control->maps, j++, MAPCONTROL) = map1;
}
arrayMax(control->maps) = j;
if (control->currentMap == map) /* pick another current map if needed */
control->currentMap = arr(control->maps, j-1, MAPCONTROL);
handleDestroy(map->handle);
controlDrawControl(control);
}
BOOL instanceExists(MAPCONTROL map, COLPROTO proto)
{ /* returns true if an instance of proto already exists on map */
int i;
COLCONTROL control = map->control;
COLINSTANCE instance;
for (i=0; i<arrayMax(control->instances); i++)
{ instance =arr(control->instances, i, COLINSTANCE);
if (instance->proto == proto && instance->map == map)
return TRUE;
}
return FALSE;
}
COLINSTANCE controlInstanceCreate(COLPROTO proto,
MAPCONTROL map,
BOOL displayed,
OBJ init,
char *name)
{
COLINSTANCE instance;
STORE_HANDLE handle = handleHandleCreate(map->handle);
instance = (COLINSTANCE) handleAlloc(proto->destroy,
handle,
sizeof(struct InstanceStruct));
instance->map = map;
instance->handle = handle;
instance->proto = proto;
instance->name = handleAlloc(0, handle, strlen(name)+1);
strcpy(instance->name, name);
instance->displayed = displayed;
instance->drawInit = 0; /* Next few function are optional */
instance->configure = 0; /* Init so the create routine needn't */
/* ACEDB-GRAPH INTERFACE: set acedb specific map field. */
if (getGraphAcedbResetSave() != NULL)
(getGraphAcedbResetSave())(&(instance->save)) ;
instance->conversionRegister = 0;
instance->setSelectBox = 0;
instance->unSelectBox = 0;
instance->doColour = 0;
instance->pick = 0;
if (!(*proto->create)(instance, init))
{ handleDestroy(instance->handle) ;
return 0;
}
return instance ;
}
/* call this to destroy graph and everything - public */
/* can also just destroy graph */
void controlDestroy(COLCONTROL control)
{
if (graphActivate(control->graph))
{
graphDestroy();
control->graph = 0 ;
}
}
/* called by graph Destroy, and by create code when it puts an new control */
/* on an existing graph */
static void controlDestroyed(void)
{
COLCONTROL control = currentColControl("controlDestroyed");
Graph old = graphActive() ;
int i;
for (i=0; i<arrayMax(control->instances); i++)
{ COLINSTANCE instance = arr(control->instances, i, COLINSTANCE);
if(instance->configGraph &&
instance->configGraph != old)
{ /* remove configure menu if it exists */
graphActivate(instance->configGraph);
graphDestroy();
graphActivate(old);
}
}
graphAssRemove(&GRAPH2COLCONTROL_ASSOC);
handleDestroy(control->handle);
}
BOOL controlSetColByName(MAPCONTROL map, char *name, int mode)
{ COLCONTROL control = map->control;
int i;
COLINSTANCE instance;
for(i=0; i<arrayMax(control->instances); i++)
{ instance = arr(control->instances, i, COLINSTANCE);
if (instance->map == map && !strcmp(instance->name, name))
switch (mode)
{
case 0:
instance->displayed = FALSE;
return TRUE;
case 1:
instance->displayed = TRUE;
return TRUE;
case 2:
instance->displayed = !instance->displayed;
return TRUE;
default:
messcrash("Illegal mode in controlSetColByName");
}
}
return FALSE;
}
void controlDrawControl(void *c)
{
COLCONTROL control = (COLCONTROL) c;
MAPCONTROL map;
COLINSTANCE instance;
BOOL active;
float offset = 0;
float oldOffset;
int i, gw, gh;
int firstFromBox = 0;
if (graphActivate(control->graph))
graphPop();
else
return;
/* The pathalogical case if no columns crashes later on unless we trap here */
if (arrayMax(control->instances) == 0)
return;
control->boxIndex = arrayReCreate(control->boxIndex, 100, COLINSTANCE);
control->boxIndex2 = arrayReCreate(control->boxIndex2, 100, void *);
assClear(control->bottomBoxes);
control->activeBox = 0;
control->fromBox = 0;
controlConvertRegister(control); /* transient conversion */
graphFitBounds(&gw, &gh);
control->graphWidth = gw;
control->graphHeight = gh;
graphClear () ;
/* draw the header */
if (control->hideHeader)
control->topMargin = 1;/* au lieu de 0 mhmp 23.10.97 */
else
{ control->topMargin = (*control->currentMap->drawHeader)(control->currentMap) ;
control->graphHeight -= 0.6; /* space for map colour bar */
}
control->halfGraphHeight = 0.5 * ( control->graphHeight -
control->topMargin );
control->lastHeaderBox = graphLastBox();
for (i=0; i<arrayMax(control->maps); i++)
{ map = array(control->maps, i, MAPCONTROL);
if (map->beforeDraw) (*map->beforeDraw)(map);
if (map->convertTrans) (*map->convertTrans)(control, map);
}
for(i=0; i<arrayMax(control->instances); i++)
{ instance = array(control->instances, i, COLINSTANCE);
if (instance->drawInit)
(*instance->drawInit)(instance);
}
active =
(array(control->instances, 0, COLINSTANCE)->map == control->currentMap);
for(i=0; i<arrayMax(control->instances); i++)
{
instance = array(control->instances, i, COLINSTANCE);
if (instance->displayed && !instance->map->suppressed)
{
oldOffset = offset;
if (!control->hideHeader &&
active != (instance->map != control->currentMap))
/* only when status changes */
{
if ((active = (instance->map != control->currentMap)))
graphColor(PALEGRAY);
else
graphColor(WHITE);
#ifdef ED_G_NEVER_INCLUDE_THIS_CODE
printf("col = %s, graphFillRectangle(%f, %f, %f, %f)\n",
instance->name,
offset, control->topMargin, offset+200, control->graphHeight) ;
#endif /* ED_G_NEVER_INCLUDE_THIS_CODE */
graphFillRectangle(offset, control->topMargin,
offset+200, control->graphHeight);
graphColor(BLACK);
}
(*instance->draw)(instance, &offset);
if (!firstFromBox && control->fromBox)
firstFromBox = control->fromBox;
if (!control->hideHeader)
{ char *cp;
char tmp[2];
int bottomBox = graphBoxStart();
int oh = graphTextHeight(0.5);
assInsert(control->bottomBoxes,
assVoid(bottomBox),
instance);
graphLine(oldOffset, control->graphHeight,
oldOffset, control->graphHeight+0.6);
graphLine(offset, control->graphHeight,
offset, control->graphHeight+0.6);
for (cp = instance->name ;
*cp && oldOffset<offset-1;
cp++, oldOffset += 0.8)
{ tmp[0] = *cp;
tmp[1] = 0;
graphText(tmp, oldOffset+0.5, control->graphHeight);
}
graphBoxEnd();
graphTextHeight(oh);
graphBoxDraw(bottomBox, BLACK, instance->map->colour);
}
}
array(control->mapTransitions, i, float) = offset;
}
graphColor (WHITE) ;
#ifdef ED_G_NEVER_INCLUDE_THIS_CODE
printf("final graphFillRectangle(%f, %f, %f, %f)\n",
offset, control->topMargin, offset+200, control->graphHeight) ;
#endif /* ED_G_NEVER_INCLUDE_THIS_CODE */
graphFillRectangle(offset, control->topMargin,
offset+200, control->graphHeight);
graphColor (BLACK) ;
if (control->currentMap->menu)
graphMenu(control->currentMap->menu);
controlOverlay() ;
graphRedraw () ;
/* ACEDB-GRAPH INTERFACE: */
if (getGraphAcedbResetKey() != NULL) (getGraphAcedbResetKey())(&(control->from)) ;
if (firstFromBox)
controlSelectBox(firstFromBox);
return;
} /* controlDrawControl */
void controlDraw(void)
{
COLCONTROL control = currentColControl("controlDraw");
controlDrawControl((void *) control);
} /* controlDraw */
void controlConvertRegister(COLCONTROL control)
{ COLINSTANCE instance;
MAPCONTROL map;
int i;
for (i=0; i<arrayMax(control->maps); i++)
{ map = array(control->maps, i, MAPCONTROL);
arrayMax(map->transConversionRoutines) = 0;
}
for(i=0; i<arrayMax(control->instances); i++)
{ instance = array(control->instances, i, COLINSTANCE);
if (instance->conversionRegister)
(*instance->conversionRegister)(control, instance);
}
}
void **controlConvert(Array conversionRoutines,
MAPCONTROL map,
void *(*conRoutine)(),
void *params)
{ struct ConversionRecord *c;
int i;
for(i=0; i<arrayMax(map->transConversionRoutines); i++)
{ c = arrp(map->transConversionRoutines, i, struct ConversionRecord );
if (c->convertRoutine == conRoutine && c->params == params)
return &c->results ;
}
c = arrayp(map->transConversionRoutines,
arrayMax(map->transConversionRoutines),
struct ConversionRecord);
c->convertRoutine = conRoutine;
c->params = params;
return &c->results;
}
void controlConvertTrans(MAPCONTROL map)
{ int i;
struct ConversionRecord *c;
for (i=0; i<arrayMax(map->transConversionRoutines); i++)
{ c = arrp(map->transConversionRoutines, i, struct ConversionRecord);
c->results = (*c->convertRoutine)(map, c->params);
}
}
void controlConvertPerm(MAPCONTROL map)
{ int i;
struct ConversionRecord *c;
for (i=0; i<arrayMax(map->permConversionRoutines); i++)
{ c = arrp(map->permConversionRoutines, i, struct ConversionRecord);
c->results = (*c->convertRoutine)(map, c->params);
}
}
void controlAddButton(MAPCONTROL map, COLOUROPT *button, MENUOPT *menu)
{
COLOUROPT **p = map->buttonsAddHere;
*p = (COLOUROPT *)halloc(sizeof(COLOUROPT), map->handle);
**p = *button; /* copies whole struct */
(*p)->next = *p;
map->buttonsAddHere = &((*p)->next);
array(map->menusOnButtons, arrayMax(map->menusOnButtons), MENUOPT *) = menu;
return;
} /* controlAddButton */
float controlDrawButtons(MAPCONTROL map, float x, float y, float max)
{
int i;
int box = graphColouredButtons(map->buttons, x, y, max);
MENUOPT *menu;
float y2 ;
for (i=0; i<arrayMax(map->menusOnButtons); i++, box++)
{ menu = arr(map->menusOnButtons, i, MENUOPT *);
if (menu)
graphBoxMenu(box, menu);
/* ACEDB-GRAPH INTERFACE: acedb may need to free a popped up menu. */
if (getGraphAcedbFreemenu() != NULL)
{
if (i == 0 && map->viewMenu) (getGraphAcedbFreemenu())(box, map->viewMenu) ;
}
}
graphBoxDim (--box, 0, 0, 0, &y2) ;
return y2 ;
}
static double dragOldy;
static void controlLeftDrag(double x, double y)
{
COLCONTROL control = currentColControl("controlLeftDrag");
graphXorLine(0, dragOldy, control->graphWidth, dragOldy);
dragOldy = y;
graphXorLine(0, y, control->graphWidth, y);
return;
} /* controlLeftDrag */
static void controlLeftUp(double x, double y)
{
COLCONTROL control = currentColControl("controlLeftUp");
graphXorLine(0, dragOldy, control->graphWidth, dragOldy);
graphRegister(LEFT_DRAG, 0);
graphRegister(LEFT_UP, 0);
return;
} /* controlLeftUp */
static void controlPick(int box, double x, double y, int modifier_unused)
{
COLCONTROL control = currentColControl("controlPick");
COLINSTANCE instance;
float x1,x2,y1,y2;
if (box && box <= control->lastHeaderBox) /* picked a header box, despatch to map */
{ if (control->currentMap->headerPick)
(*control->currentMap->headerPick)(control->currentMap, box, x, y);
return;
}
if (box && assFind(control->bottomBoxes, assVoid(box), &instance))
/* a bottom coloured box, click here to configure */
{
if (instance->configure)
{
if ((*instance->configure)(instance))
{
/* ACEDB-GRAPH INTERFACE: set acedb specific map field. */
if (getGraphAcedbResetKey() != NULL) (getGraphAcedbResetKey())(&(instance->map->viewKey)) ;
controlDrawControl(control);
}
}
return;
}
/* Second click: follow it */
if (box && box == control->activeBox)
{ instance = array(control->boxIndex, box, COLINSTANCE);
if (instance && instance->followBox)
(*instance->followBox)(instance, box, x, y);
return;
}
/* if (!box)
controlMiddleUp(x,y); il rm 12/6/97 srk added for some reason 4/3/97 ??? */
instance = array(control->boxIndex, box, COLINSTANCE);
if (instance && instance->pick)
{ (*instance->pick)(instance, box, x, y);
return;
}
controlSelect(box, x, y);
if (box == 0 && control->needRuler)
{ graphBoxDim(0, &x1, &y1, &x2, &y2);
y += y1;
dragOldy = y;
graphXorLine(0, y, control->graphWidth, y);
graphRegister(LEFT_DRAG, (GraphFunc)controlLeftDrag);
graphRegister(LEFT_UP, (GraphFunc)controlLeftUp);
}
return;
} /* controlPick */
static void controlSelect(int box, double x, double y)
{
COLCONTROL control = currentColControl("controlSelect");
COLINSTANCE instance;
MAPCONTROL newMap = control->currentMap;
BOOL redrawOld = FALSE, redrawNew = FALSE, redrawMap = FALSE;
int i;
/* first deselect any previous box */
if (control->activeBox)
{ instance = array(control->boxIndex, control->activeBox, COLINSTANCE);
if (instance && instance->unSelectBox)
redrawOld = (*instance->unSelectBox)(instance, control->activeBox);
}
/* Now set the new one as selected */
control->activeInstance = 0;
/* ACEDB-GRAPH INTERFACE: set acedb specific field. */
if (getGraphAcedbResetKey() != NULL) (getGraphAcedbResetKey())(&(control->activeKey)) ;
if (box == 0 && x > 0) /* Pick in no box, can still change map*/
{ /* switch current map if necessary */
for(i=0; i<arrayMax(control->instances); i++)
{ if (array(control->mapTransitions, i, float) > x)
{ newMap = array(control->instances, i, COLINSTANCE)->map;
break;
}
}
}
else
{
instance = array(control->boxIndex, box, COLINSTANCE);
if (instance && instance->setSelectBox)
{ control->activeInstance = instance;
redrawNew = (*instance->setSelectBox)(instance, box, x, y);
newMap = instance->map;
}
}
redrawMap = newMap != control->currentMap;
control->currentMap = newMap;
if (redrawOld || redrawNew || redrawMap)
controlDraw();
else
controlOverlay();
return;
} /* controlSelect */
void controlOverlay(void)
{
COLCONTROL control = currentColControl("controlOverlay");
COLINSTANCE instance;
int i;
control->activeBox = 0;
for (i=0; i<arrayMax(control->boxIndex); i++)
{ instance = array(control->boxIndex, i, COLINSTANCE);
if (instance && instance->doColour)
(*instance->doColour)(instance, i);
/* this call sets control->activeBox */
}
return;
} /* controlOverlay */
void controlUnselectAll(void)
/* Public function to unhighlight the currently highlit thing */
{
controlSelect(0, -1, 0);
}
void controlSelectBox(box)
/* Public function to highlight the thing in box */
{
controlSelect(box, -1, 0);
}
static void controlKybd(int k, int modifier_unused)
{
MAPCONTROL map = currentMapControl();
if (map->keyboard)
(*(map->keyboard))(k);
}
void controlPrint (void)
{
COLCONTROL control = currentColControl("controlPrint");
MAPCONTROL map = control->currentMap;
float oldMin = map->min;
float oldMax = map->max;
float oldCentre = map->centre;
BOOL oldHH = control->hideHeader;
float min, max, mag;
int nx, ny;
ACEIN zone_in;
graphFitBounds (&nx, &ny) ;
zone_in = messPrompt("Please state the zone you wish to print",
messprintf("%g %g", map->min, map->max),
"ffz", 0);
if (!zone_in)
return ;
aceInFloat (zone_in, &min) ;
aceInFloat (zone_in, &max) ;
aceInDestroy (zone_in);
if (min >= max)
return ;
map->min = min;
map->max = max;
map->centre = (max+min)/2.0;
control->hideHeader = TRUE;
mag = map->mag > 0 ? map->mag : -map->mag;
graphBoundsPrint (nx + 0.2, 1.05 * (max - min) * mag + 5, controlDraw) ;
map->min = oldMin;
map->max = oldMax;
map->centre = oldCentre;
control->hideHeader = oldHH;
controlDrawControl(control);
} /* controlPrint */
/************************************/
/* a few utility functions (public) */
/************************************/
/* set/read box to private data mapping */
void controlRegBox(COLINSTANCE instance, int box, void *private)
{
COLCONTROL control = instance->map->control;
array(control->boxIndex, box, COLINSTANCE) = instance;
array(control->boxIndex2, box, void *) = private;
return ;
}
int controlBoxRegd(COLINSTANCE instance, int box)
{
void *v_ptr = arr(instance->map->control->boxIndex2, box, void *) ;
return assInt(v_ptr) ;
}
/* utility func which helps truncate column drawing:
coord is y value in map coords, slop is how far above/below that we will
draw, ret is given translated graph co-ord, truncated if needed.
returns FALSE is truncation done, TRUE otherwise . */
BOOL controlCheckY(MAPCONTROL map, float coord, float slop, float *ret)
{ COLCONTROL control = map->control;
float gco = MAP2GRAPH(map, coord);
if (gco < (control->topMargin + slop + 0.1))
{ if (ret)
*ret = control->topMargin + 0.1;
return FALSE;
}
if (gco > (control->graphHeight - (0.1 + slop)))
{ if (ret)
*ret = control->graphHeight - 0.1;
return FALSE;
}
if (ret)
*ret = gco;
return TRUE;
}
void controlTruncatedLine(COLCONTROL control, float x1, float y1,
float x2, float y2)
/* x2, y2 is assumed to be between topMargin and graphHeight */
/* x1, y1 can be outside, draw part if line bewteen tm and gh */
{ float t = control->topMargin;
float b = control->graphHeight;
if (y1 > t && y1 < b)
graphLine(x1, y1, x2, y2);
else if (y1 <= t)
{ float crossx = x1 + (x2-x1)*(control->topMargin-y1)/(y2-y1);
graphLine(crossx, control->topMargin, x2, y2);
}
else
{ float crossx = x1 + (x2-x1)*(y1-control->graphHeight)/(y1-y2);
graphLine(crossx, control->graphHeight, x2, y2);
}
}
/*************************************************************************/
/* A few columns for use anywhere, which depend only on map information. */
/*************************************************************************/
static void mapLocatorDrawInit(COLINSTANCE instance)
{
MAPCONTROL map = instance->map;
COLCONTROL control = map->control ;
float y0, yn;
y0 = 1 + control->topMargin ;
yn = control->graphHeight - 1;
if (map->mag < 0)
{ map->thumb.offset = map->max ;
map->thumb.fac = (y0 - yn) / (map->max - map->min) ;
}
else
{ map->thumb.offset = map->min ;
map->thumb.fac = (yn - y0) / (map->max - map->min) ;
}
map->thumb.halfwidth = 0.5 * map->thumb.fac *
(control->graphHeight-control->topMargin-2.0) / map->mag;
map->thumb.x = 0 ;
map->thumb.drawn = FALSE;
map->cursor.drawn = FALSE; /* In case scale instance removed */
}
static void mapLocatorDraw (COLINSTANCE instance, float *offset)
{ float y;
MAPCONTROL map = instance->map;
COLCONTROL control = map->control ;
float t, b;
*offset += 1;
map->thumb.x = *offset;
map->thumb.drawn = TRUE;
#ifdef ED_G_NEVER_INCLUDE_THIS_CODE
printf("final graphFillRectangle(%f, %f, %f, %f)\n",
*offset - 0.25, MAP2WHOLE(map, map->min),
*offset + 0.25, MAP2WHOLE(map, map->max));
#endif /* ED_G_NEVER_INCLUDE_THIS_CODE */
graphFillRectangle (*offset - 0.25, MAP2WHOLE(map, map->min),
*offset + 0.25, MAP2WHOLE(map, map->max));
y = MAP2WHOLE(map, map->centre);
map->thumb.box = graphBoxStart();
t = y - map->thumb.halfwidth;
b = y + map->thumb.halfwidth;
if (t < control->topMargin)
t = control->topMargin;
if (b > control->graphHeight)
b = control->graphHeight;
if (b > control->topMargin &&
t < control->graphHeight)
graphRectangle (*offset - 0.5, t, *offset + 0.5, b) ;
graphBoxEnd();
graphBoxDraw (map->thumb.box, DARKGREEN, GREEN);
array(control->boxIndex, map->thumb.box, COLINSTANCE) = instance;
if (map->cursor.drawn && map->hasProjectionLines)
{ controlTruncatedLine(control, *offset,
y - map->thumb.halfwidth,
map->cursor.x,
control->topMargin+1);
controlTruncatedLine(control, *offset,
y + map->thumb.halfwidth,
map->cursor.x,
control->graphHeight-1);
}
*offset += 1;
}
static void mapThumbDrag (float *x, float *y, BOOL isDone)
{
COLCONTROL control = currentColControl("mapThumbDrag");
MAPCONTROL map = control->thumbMap;
float top, bottom;
/* fix x */
*x = map->thumb.x - 0.5;
/* stop the user pulling the thumb bar out of the extent */
top = MAP2WHOLE(map, map->min);
bottom = MAP2WHOLE(map, map->max);
if (map->thumb.fac < 0 )
{ float tmp = bottom;
bottom = top;
top = tmp;
}
if (*y < top)
*y = top;
if ((*y + 2 * map->thumb.halfwidth) > bottom)
*y = bottom - 2 * map->thumb.halfwidth;
if (isDone)
{ map->centre = WHOLE2MAP(map, *y + map->thumb.halfwidth);
controlDraw();
}
}
static void mapLocatorPick(COLINSTANCE instance,
int box,
double x,
double y)
{
instance->map->control->thumbMap = instance->map;
graphBoxDrag(box, mapThumbDrag);
} /* mapLocatorPick */
struct configMapLocal{
float magConf;
BOOL lines;
};
static BOOL mapLocatorConfigure (COLINSTANCE instance)
{
MAPCONTROL map = instance->map;
struct configMapLocal *cf = (struct configMapLocal *) messalloc(sizeof(struct configMapLocal));
float line = 2.0;
if(controlCreateConfig(instance,cf,"Configure Locator column",0.5,0.15)){
/* initialise data */
cf->magConf = map->magConf;
cf->lines = map->hasProjectionLines;
graphFloatEditor("Magnification :",&cf->magConf,4.0,line++,0);
graphToggleEditor("Show projection Lines",&cf->lines,4.0,line++);
graphRedraw();
}
return FALSE;
} /* mapLocatorConfigure */
static void mapLocatorConfigFinal (COLINSTANCE instance, void *locals, BOOL ok)
{
MAPCONTROL map = instance->map;
struct configMapLocal *cf = locals;
if(ok)
{
map->magConf = cf->magConf;
if (map->magConf != 0.0)
map->mag = map->magConf;
map->hasProjectionLines = cf->lines;
}
else
messfree(cf);
return;
} /* mapLocatorConfigFinal */
static BOOL mapLocatorCreate (COLINSTANCE instance, OBJ init)
{
MAPCONTROL map = instance->map;
instance->draw = mapLocatorDraw;
instance->drawInit = mapLocatorDrawInit;
instance->pick = mapLocatorPick;
instance->configure = mapLocatorConfigure;
instance->configFinal = mapLocatorConfigFinal;
map->hasProjectionLines = TRUE; /* default */
map->magConf = map->mag ; /* map->magConf = 0; mhmp 24.10.97*/
/* ACEDB-GRAPH INTERFACE: Call acedb specific code if registered to get */
/* magnification and projection. */
if (getGraphAcedbMapLocate() != NULL)
(getGraphAcedbMapLocate())(init, &(instance->save), map) ;
return TRUE ;
} /* mapLocatorCreate */
static void mapWhole (void *m)
{
BOOL isNeg ;
MAPCONTROL map = (MAPCONTROL) m;
map->centre = (map->max + map->min) / 2.0 ;
isNeg = (map->mag < 0) ;
map->mag = (map->control->graphHeight - map->control->topMargin - 2.0) /
(map->max - map->min) ;
if (isNeg)
map->mag = -map->mag ;
controlDraw() ;
return;
} /* mapWhole */
static void mapZoomIn (void *m)
{
MAPCONTROL map = (MAPCONTROL) m;
map->mag *= 2 ;
controlDraw() ;
return;
} /* mapZoomIn */
static void mapZoomOut (void *m)
{
MAPCONTROL map = (MAPCONTROL) m;
map->mag /= 2 ;
controlDraw() ;
return;
} /* mapZoomOut */
static void mapLocatorInit(COLPROTO proto, MAPCONTROL map)
{
COLOUROPT *button;
button = (COLOUROPT *) messalloc(sizeof(COLOUROPT));
button->text = "Whole";
button->f = mapWhole;
button->arg = (void *) map;
button->fg = BLACK;
button->bg = WHITE;
button->next = 0;
controlAddButton(map, button, 0);
button->text = "Zoom in";
button->f = mapZoomIn;
button->arg = (void *) map;
button->fg = BLACK;
button->bg = WHITE;
button->next = 0;
controlAddButton(map, button, 0);
button->text = "Zoom out";
button->f = mapZoomOut;
button->arg = (void *) map;
button->fg = BLACK;
button->bg = WHITE;
button->next = button; /* Terminator */
controlAddButton(map, button, 0);
messfree(button);
return;
} /* mapLocatorInit */
struct ProtoStruct mapLocatorColumn = {
mapLocatorInit,
mapLocatorCreate,
0,
"Locator",
0,
TRUE,
0,
0,
"The locator column displays a green slider bar which can be used to "
"control the position of the map display.\n\n"
"The magnification configuration option can be used to set a specific "
"factor between map co-ordinates and screen distances in character "
"size units. If a configuration is saved with a magnification set, "
"that will be used for initial display in preference to defaults "
"or information derived from the displayed object.\n\n"
"The \"Show projection lines\" toggle controls the lines "
"drawn between the green bar on the locator and the ends "
"of the scale, if it exists.\n"
};
/************************************************************/
/* scroller, to be used from giface/netscape */
static void mapScrollerDrawInit(COLINSTANCE instance)
{
}
static void mapScrollerDraw(COLINSTANCE instance, float *offset)
{
MAPCONTROL map = instance->map;
COLCONTROL control = map->control ;
int i, box ;
float t, b, y1, y2 ;
Array aa = 0 ;
*offset += 1.5;
box = graphBoxStart () ;
t = GRAPH2MAP(map, control->topMargin + 1) ;
t = MAP2WHOLE (map, t) ;
if (t < control->topMargin + .2)
t = control->topMargin + .2 ;
b = GRAPH2MAP(map, control->graphHeight-1) ;
b = MAP2WHOLE (map, b) ;
if (b > control->graphHeight)
b = control->graphHeight ;
#ifdef ED_G_NEVER_INCLUDE_THIS_CODE
printf("final graphFillRectangle(%f, %f, %f, %f)\n",
*offset - 0.5, t, *offset + 0.5, b) ;
#endif /* ED_G_NEVER_INCLUDE_THIS_CODE */
graphFillRectangle (*offset - 0.5, t, *offset + 0.5, b) ;
aa = arrayCreate (8, float) ; i = 0 ;
y1 = control->topMargin + 1. ;
y2 = control->topMargin + 2. ;
if (y1 < t )
{
array (aa, i++, float) = *offset ;
array (aa, i++, float) = y1 ;
array (aa, i++, float) = *offset + .5 ;
array (aa, i++, float) = y2 ;
array (aa, i++, float) = *offset - .5 ;
array (aa, i++, float) = y2 ;
array (aa, i++, float) = *offset ;
array (aa, i++, float) = y1 ;
graphPolygon (aa) ;
graphLine (*offset, t, *offset, y2) ;
}
arrayDestroy (aa) ;
aa = arrayCreate (8, float) ;
y1 = control->graphHeight - 1. ;
y2 = control->graphHeight - 2. ;
i = 0 ;
if (y1 > b )
{
array (aa, i++, float) = *offset ;
array (aa, i++, float) = y1 ;
array (aa, i++, float) = *offset + .5 ;
array (aa, i++, float) = y2 ;
array (aa, i++, float) = *offset - .5 ;
array (aa, i++, float) = y2 ;
array (aa, i++, float) = *offset ;
array (aa, i++, float) = y1 ;
graphPolygon (aa) ;
graphLine (*offset, b, *offset, y2) ;
}
arrayDestroy (aa) ;
graphBoxEnd();
graphBoxDraw (box, DARKGREEN, WHITE);
array(control->boxIndex, box, COLINSTANCE) = instance;
*offset += 1;
}
static void mapScrollerInit(COLPROTO proto, MAPCONTROL map)
{
}
static void mapScrollerPick(COLINSTANCE instance,
int box,
double x,
double y)
{
instance->map->centre = WHOLE2MAP (instance->map,
y + instance->map->control->topMargin + 1) ;
controlDraw() ;
}
static BOOL mapScrollerCreate(COLINSTANCE instance, OBJ init)
{
instance->draw = mapScrollerDraw;
instance->drawInit = mapScrollerDrawInit;
instance->pick = mapScrollerPick;
return TRUE ;
}
struct ProtoStruct mapScrollerColumn = {
mapScrollerInit,
mapScrollerCreate,
0,
"Scroller",
0,
0,
0,
0,
"The scroller column displays a scroll bar which is "
" sensitive to the left mouse button and hance may by "
" used from Netscpape. \n\n"
};
/************************************************************/
void mapControlCursorSet (MAPCONTROL map, float x)
{
if (x > 0)
map->cursor.val = 0.5 + x / map->cursor.unit ;
else
map->cursor.val = -0.5 + x / map->cursor.unit ;
if (map->hasCursor && !map->cursor.box) /* off screen before, draw it now. */
controlDrawControl(map->control);
else
mapControlCursorShift (map) ;
}
void mapControlCursorShift (MAPCONTROL map)
{
float x1, x2, y1, y2, z = mapControlCursorPos(map) ;
if (!map->cursor.box)
return ;
graphBoxDim (map->cursor.box, &x1, &y1, &x2, &y2) ;
strcpy (map->cursor.text, messprintf ("%.*f", map->cursor.resolution, z)) ;
y1 = MAP2GRAPH(map, mapControlCursorPos(map)) ;
graphBoxShift (map->cursor.box, x1, y1-0.5) ;
}
static void mapControlFindScaleUnit (MAPCONTROL map, float *u, float *sub)
{
float cutoff = 5 / map->mag ;
float unit = *u ;
float subunit = *u ;
if (cutoff < 0)
cutoff = -cutoff ;
while (unit < cutoff)
{ unit *= 2 ;
subunit *= 5 ;
if (unit >= cutoff)
break ;
unit *= 2.5000001 ; /* safe rounding */
if (unit >= cutoff)
break ;
unit *= 2 ;
subunit *= 2 ;
}
subunit /= 10 ;
if (subunit > *sub)
*sub = subunit ;
*u = unit ;
}
static void mapScaleDrawInit(COLINSTANCE instance)
{
MAPCONTROL map = instance->map;
map->cursor.x = 0;
map->cursor.drawn = FALSE;
map->thumb.drawn = FALSE; /* In case locator instance removed */
}
static void mapScaleDraw (COLINSTANCE instance, float *offset)
{
MAPCONTROL map = instance->map;
float unit = map->scaleUnit;
float subunit = unit/10.0;
float x, y ;
int resolution, max = 0 ;
char *cp = 0 ;
COLCONTROL control = map->control ;
map->cursor.x = *offset+1.5;
map->cursor.drawn = TRUE;
map->cursor.box = 0;
mapControlFindScaleUnit (map, &unit, &subunit) ;
if (unit >= 1)
resolution = 0 ;
else if (unit >= .1)
resolution = 1 ;
else if (unit >= .01)
resolution = 2 ;
else if (unit >= .001)
resolution = 3 ;
else
resolution = 0 ;
x = GRAPH2MAP(map, control->topMargin+1) ;
x = unit * ((((x>=0)^(map->mag<0))?1:0) + (int)(x/unit)) ;
while ((y = MAP2GRAPH(map, x)) < control->graphHeight - 0.95)
{ graphLine (*offset+0.5,y,*offset+1.5,y) ;
cp = messprintf ("%-4.*f", resolution, x) ;
graphText (cp, *offset+2, y-0.5) ;
if (strlen(cp)+3 > max)
max = 3+strlen(cp) ;
if (map->mag >0)
x += unit ;
else
x -= unit;
}
x = GRAPH2MAP(map, control->topMargin+1) ;
x = subunit * ((((x>=0)^(map->mag<0))?1:0) + (int)(x/subunit)) ;
while ((y = MAP2GRAPH(map, x)) < control->graphHeight - 1.5)
{ graphLine (*offset+1.0,y,*offset+1.5,y) ;
if (map->mag >0)
x += subunit ;
else
x -= subunit;
}
graphLine (*offset+1.5, control->topMargin+1,
*offset+1.5, control->graphHeight-1 ) ;
if (map->thumb.drawn && map->hasProjectionLines)
{ controlTruncatedLine(control, map->thumb.x,
MAP2WHOLE(map, map->centre) - map->thumb.halfwidth,
*offset+1.5, control->topMargin+1) ;
controlTruncatedLine(control, map->thumb.x,
MAP2WHOLE(map, map->centre) + map->thumb.halfwidth,
*offset+1.5, control->graphHeight-1.0) ;
}
if (map->hasCursor && !control->hideHeader)
{
float z = mapControlCursorPos(map) ;
float y = MAP2GRAPH(map, z) ; /* Jean - your x here was a bug */
float thumbx = map->thumb.drawn ? map->thumb.x : 0;
if (y > control->topMargin+1 && y < control->graphHeight -1)
{
if (map->cursor.unit >= .99)
map->cursor.resolution = 0 ;
else if (map->cursor.unit >= .099)
map->cursor.resolution = 1 ;
else if (map->cursor.unit >= .0099)
map->cursor.resolution = 2 ;
else if (map->cursor.unit >= .00099)
map->cursor.resolution = 3 ;
else
map->cursor.resolution = 0 ;
strcpy (map->cursor.text,
messprintf ("%.*f", map->cursor.resolution, z)) ;
map->cursor.box = graphBoxStart() ;
graphLine (thumbx, y, control->graphWidth+1, y);
map->cursor.pickBox = graphBoxStart() ;
if (max < 3.0+strlen(map->cursor.text))
max = 3.0+strlen(map->cursor.text);
graphColor (LIGHTGREEN) ;
#ifdef ED_G_NEVER_INCLUDE_THIS_CODE
printf("final graphFillRectangle(%f, %f, %f, %f)\n",
*offset+0.5, y-0.5,
*offset+max-0.5, y+0.5) ;
#endif /* ED_G_NEVER_INCLUDE_THIS_CODE */
graphFillRectangle (*offset+0.5, y-0.5,
*offset+max-0.5, y+0.5) ;
graphColor (BLACK) ;
graphTextPtr (map->cursor.text, *offset+0.5,
y-0.5, strlen(map->cursor.text)) ;
graphBoxEnd () ;
graphBoxEnd () ;
graphBoxSetPick (map->cursor.box, FALSE) ; /* only pick on .pickBox */
array(control->boxIndex, map->cursor.pickBox, COLINSTANCE) = instance;
graphBoxDraw (map->cursor.box, BLACK, TRANSPARENT) ;
}
}
*offset += max ;
}
static void mapControlCursorDrag (float *x, float *y, BOOL isDone)
{
COLCONTROL control = currentColControl("mapControlCursorDrag");
MAPCONTROL map = control->thumbMap;
*x = map->cursor.x - 1.0;
if (*y < control->topMargin + 0.5)
*y = control->topMargin + 0.5;
if (*y > control->graphHeight - 1.5)
*y = control->graphHeight - 1.5;
if (isDone)
mapControlCursorSet (map, GRAPH2MAP(map, *y+0.5)) ;
}
static void mapScalePick(COLINSTANCE instance,
int box,
double x,
double y)
{
instance->map->control->thumbMap = instance->map;
graphBoxDrag(box, mapControlCursorDrag);
}
struct configLocalsName{
float scale,cursor;
BOOL showCursor;
};
static BOOL mapScaleConfigure(COLINSTANCE instance)
{
MAPCONTROL map = instance->map;
struct configLocalsName *cf = (struct configLocalsName *) messalloc(sizeof(struct configLocalsName));
float line = 2.0;
/* internal representation depends on cursor unit */
if(controlCreateConfig(instance,cf,"Configure Scale column",0.5,0.15)){
/* initialise data */
cf->scale = map->scaleUnit;
cf->cursor = map->cursor.unit;
cf->showCursor = map->hasCursor;
graphFloatEditor("Scale unit:",&cf->scale,4.0,line++,0);
graphFloatEditor("Cursor unit:",&cf->cursor,4.0,line++,0);
graphToggleEditor("Show cursor",&cf->showCursor,4.0,line++);
graphRedraw();
}
return FALSE;
}
static void mapScaleConfigFinal(COLINSTANCE instance, void *locals, BOOL ok)
{
struct configLocalsName *cf = locals;
MAPCONTROL map = instance->map;
float old = mapControlCursorPos(map);
if(ok)
{
map->hasCursor = cf->showCursor;
map->scaleUnit = cf->scale;
if (map->scaleUnit <0.0001)
map->scaleUnit = 0.0001;
map->cursor.unit = cf->cursor;
if (map->cursor.unit < 0.001)
map->cursor.unit = 0.001;
if (old > 0)
map->cursor.val = 0.5 + old / map->cursor.unit ;
else
map->magConf = 0.0;
}
else
messfree(cf);
}
static BOOL mapScaleCreate(COLINSTANCE instance, OBJ init)
{
MAPCONTROL map = instance->map;
instance->draw = mapScaleDraw;
instance->drawInit = mapScaleDrawInit;
instance->pick = mapScalePick;
instance->configure = mapScaleConfigure;
instance->configFinal = mapScaleConfigFinal;
map->cursor.val = 0;
map->cursor.unit = 1.0;
map->scaleUnit = 0.01;
map->hasCursor = FALSE;
/* ACEDB-GRAPH INTERFACE: Call acedb specific code if registered to get */
/* scale information. */
if (getGraphAcedbScale() != NULL)
(getGraphAcedbScale())(init, &(instance->save), map) ;
return TRUE ;
}
struct ProtoStruct mapScaleColumn = {
0,
mapScaleCreate,
0,
"Scale",
0,
TRUE,
0,
0,
"The scale column shows a ruler scale with map co-ordinates, and "
"optionally a cursor and indicator line.\n\n"
"The \"cursor unit\" configuration option controls the distance by "
"which the up and down arrows move the cursor.\n\n"
"The \"scale unit\" configuration option controls the smallest "
"difference between two scale ticks which can be drawn."
};
/************************************************************************/
static void spacerDraw(COLINSTANCE instance, float *offset)
{ SPACERPRIV private = instance->private;
COLCONTROL control = instance->map->control;
if (private->colour != WHITE) /* white == transparent */
{ graphColor(private->colour);
#ifdef ED_G_NEVER_INCLUDE_THIS_CODE
printf("final graphFillRectangle(%f, %f, %f, %f)\n",
*offset, control->topMargin,
*offset + private->width, control->graphHeight);
#endif /* ED_G_NEVER_INCLUDE_THIS_CODE */
graphFillRectangle(*offset, control->topMargin,
*offset + private->width, control->graphHeight);
graphColor(BLACK);
}
*offset += private->width;
}
struct spacerLocal{
float width;
int colour;
};
static BOOL spacerConfigure(COLINSTANCE instance)
{ SPACERPRIV private = instance->private;
struct spacerLocal *cf = (struct spacerLocal *) messalloc(sizeof(struct spacerLocal));
float line = 2.0;
if(controlCreateConfig(instance,cf,"Configure spacer column",0.5,0.15)){
/* initialise data */
cf->width = private->width;
cf->colour = private->colour;
graphFloatEditor("Column width:",&cf->width,4.0,line++,0);
graphColourEditor(" "," ",&cf->colour,4.0,line);
graphRedraw();
}
return FALSE;
}
static void spacerConfigFinal(COLINSTANCE instance, void *locals, BOOL ok){
SPACERPRIV private = instance->private;
struct spacerLocal *cf = locals;
if(ok){
private->colour = cf->colour;
private->width = cf->width;
}
else
messfree(cf);
}
static BOOL spacerCreate(COLINSTANCE instance, OBJ init)
{
SPACERPRIV private = (SPACERPRIV)handleAlloc(0, instance->handle, sizeof(struct SpacerPriv));
instance->private = private;
instance->draw = spacerDraw;
instance->configure = spacerConfigure;
instance->configFinal = spacerConfigFinal;
private->width = 1.0;
private->colour = WHITE;
/* ACEDB-GRAPH INTERFACE: Call acedb specific code if registered to get */
/* space information. */
if (getGraphAcedbSpace() != NULL)
(getGraphAcedbSpace())(init, &(instance->save), private) ;
return TRUE;
}
struct ProtoStruct spacerColumn = {
0,
spacerCreate,
0,
"Spacer",
0,
FALSE,
0,
0,
"The spacer column provides space in the map display, of user specified "
"width and colour. The width is specified in units equal to the width of "
"a single character on the display"
};
/*************************************************/
/************* middle button for thumb **********/
static double oldx, oldy, oldDy ;
static BOOL dragFast ;
static void controlMiddleDrag (double x, double y)
{
MAPCONTROL map = currentMapControl();
if(dragFast)
{ graphXorLine (0, oldy - oldDy, map->thumb.x, oldy - oldDy) ;
graphXorLine (0, oldy + oldDy, map->thumb.x, oldy + oldDy) ;
}
else
graphXorLine (map->thumb.x, oldy, map->control->graphWidth, oldy) ;
oldy = y ;
if(dragFast)
{ oldDy *= exp ((x - oldx) / 25.) ;
oldx = x ;
graphXorLine (0, y - oldDy, map->thumb.x, y - oldDy) ;
graphXorLine (0, y + oldDy, map->thumb.x, y + oldDy) ;
}
else
graphXorLine (map->thumb.x, y, map->control->graphWidth, y) ;
}
static void controlMiddleUp (double x, double y)
{ float x1,x2,y1,y2 ;
MAPCONTROL map = currentMapControl();
if (dragFast)
{ graphBoxDim (map->thumb.box, &x1, &y1, &x2, &y2) ;
map->mag *= (y2 - y1) / (2. * oldDy) ;
map->centre = WHOLE2MAP(map, y) ;
}
else
map->centre = GRAPH2MAP(map,y) ;
controlDraw();
}
static void controlMiddleDown (double x, double y)
{ float x1 = 0, x2 = 0, y1 = 0 , y2 = 1 ;
MAPCONTROL map = currentMapControl();
if (map->thumb.box)
graphBoxDim (map->thumb.box, &x1, &y1, &x2, &y2) ;
oldDy = (y2 - y1) / 2. ;
dragFast = (x < map->thumb.x) ;
if (dragFast)
{ graphXorLine (0, y - oldDy, map->thumb.x, y - oldDy) ;
graphXorLine (0, y + oldDy, map->thumb.x, y + oldDy) ;
}
else
graphXorLine (map->thumb.x, y, map->control->graphWidth, y) ;
oldx = x ;
oldy = y ;
graphRegister (MIDDLE_DRAG, controlMiddleDrag) ; /* must redo */
graphRegister (MIDDLE_UP, controlMiddleUp) ;
}
|