/usr/lib/libreoffice/share/extensions/DmathsAddon/OOoTep/Module1.xba is in libreoffice-dmaths 3.4+dfsg1-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 | <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE script:module PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "module.dtd">
<script:module xmlns:script="http://openoffice.org/2000/script" script:name="Module1" script:language="StarBasic">'OOoTep
'Copyright (C) 2005-2006 Gilles Daurat
'This program 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110 - 1301, USA.
Option Explicit
Public Const VERSION_OOOTEP = "2010.04.03"
Public Const DEBUG = FALSE
Public Const EPSILON = 0.000001
Public Const AL_HAUT = 0
Public Const AL_CENTRE = 1
Public Const AL_BAS = 2
Public Const AL_GAUCHE = 3
Public Const AL_DROITE = 4
Public const TEP_POINT = 0
Public const TEP_DROITE = 1
Public const TEP_DROITEEQ = 2
Public const TEP_DROITEEQR = 3
Public const TEP_DROITEV = 4
Public Const TEP_SEGMENT = 5
Public Const TEP_DEMIDROITE = 6
Public Const TEP_POLYGONE = 7
Public Const TEP_VECTEUR = 8
Public Const TEP_CERCLE = 9
Public Const TEP_CERCLEDIA = 10
Public Const TEP_CERCLERAYON = 11
Public Const TEP_DROITEPARALLELE = 12
Public Const TEP_DROITEPERPENDICULAIRE = 13
Public Const TEP_ROTATION = 14
Public Const TEP_TRANSLATION = 15
Public Const TEP_SYMETRIQUEPOINT = 16
Public Const TEP_SYMETRIQUEDROITE = 17
Public Const TEP_ARC = 18
Public Const TEP_ANGLE = 19
Public Const TEP_HOMOTHETIE = 20
Public Const TEP_GROUPE = 21
Public Const TEP_VARIABLE = 22
Public Const TEP_TEXTE = 23
Public Const TEP_SIMILITUDE = 24
Public Const TEP_FONCTION = 25
Public Const TEP_REEL = 26
Public Const TEP_DROITEANGLE = 27
Public oPageDessin as Object
Public oDocumentDessin as Object
Public oPageTexte as Object
Public oDocumentTexte as Object
Public oPagePremier as object
Public oPremierDocument as Object
Public oGroupeDessin as Object
Public nomFichier as string
Public NbObjet as integer
Public Sorte(0 to 10000) as integer
Public Parametres(0 to 10000) as string
Public Nom(0 to 10000) as string
Public xorig as double
Public yorig as double
Public xunit as double
Public yunit as double
Public pasx as double
Public pasy as double
Public xmin as double
Public ymin as double
Public xmax as double
Public ymax as double
Public trame as Boolean
Public grille as Boolean
Public ligne() as string
Public options() as string
Public coords() as string
Sub Main
AfficheDialog1()
End Sub
Function ChargeFonction(unNom as string) as String
Dim param() as string
dim i
dim oootepTrouve as Boolean
oootepTrouve = False
for i = lbound(ligne) to ubound(ligne)
if ChargeParametre(ligne(i), param(), ";") > 0 then
if param(0) = "@oootep" then oootepTrouve = True
if param(0) = unNom and oootepTrouve then ChargeFonction = ligne(i)
end if
next i
End Function
Sub ChargeLimite()
Dim i
dim param() as String
dim p1() as string
trame = False
grille = False
For i = lbound(ligne) to ubound(ligne)
ChargeParametre(ligne(i), param, ";")
if param(0) = "fenetre" then
ChargeParametre(param(1), p1, ",")
xmin = p1(0)
xmax = p1(1)
ymax = p1(3)
ymin = p1(2)
xunit = CDbl(p1(4)) * 1000 / 30
yunit = CDbl(p1(5)) * 1000 / 30
ligne(i) = ""
end if
if param(0) = "trame" then
trame = True
End if
if param(0) = "grille" then
grille = True
End if
next i
if xmin > xmax then Echange(xmin, xmax)
if ymin > ymax then Echange(ymin, ymax)
End Sub
Sub AjouteAire(unNom As String, listeObjets as String, options as String)
Dim lesObjets() as String
Dim uneAire as Double
Dim p1() as String
Dim p2() as String
Dim p3() as String
ChargeParametre(listeObjets, lesObjets, ",")
if Sorte(ChercheObjet(lesObjets(0))) = TEP_CERCLE then
ChargeParametre(Parametres(ChercheObjet(lesObjets(0))), p1, ";")
uneAire = Pi * CDbl(p1(2))^2
Else
if Sorte(ChercheObjet(lesObjets(0))) = TEP_POLYGONE then
ChargeParametre(Parametres(ChercheObjet(lesObjets(0))), lesObjets, ";"
end if
ChargeParametre(Parametres(ChercheObjet(lesObjets(0))), p3, ";")
uneAire = 0
for i = LBound(lesObjets) + 1 to UBound(lesObjets) - 1
ChargeParametre(Parametres(ChercheObjet(lesObjets(i))), p1, ";")
ChargeParametre(Parametres(ChercheObjet(lesObjets(i + 1))), p2, ";")
uneAire = uneAire + CalculeAireTriangle(val(p1(0)), val(p1(1)), val(p2(0)), val(p2(1)), val(p3(0)), val(p3(1)))
next i
end if
Nom(NbObjet) = unNom
Sorte(NbObjet) = TEP_VARIABLE
Parametres(NbObjet) = trim(str(uneAire))
NbObjet = NbObjet + 1
End Sub
Sub AjouteArc(unNom as String, listeObjets as String, options as String, sType as Integer)
Dim lesObjets() as String
Dim p1() as String
Dim p2() as String
Dim p3() as String
Dim unRayon as Double
Dim ang1 as Double
Dim ang2 as Double
Dim unTrait as Object
ChargeParametre(listeObjets, lesObjets, ",")
ChargeParametre(Parametres(ChercheObjet(lesObjets(0))), p1, ";")
ChargeParametre(Parametres(ChercheObjet(lesObjets(1))), p2, ";")
ChargeParametre(Parametres(ChercheObjet(lesObjets(2))), p3, ";")
if sType = TEP_ARC then
unRayon = sqr((val(p1(0)) - val(p2(0)))^2 + (val(p1(1)) - val(p2(1)))^2)
else
unRayon = min(sqr((val(p1(0)) - val(p2(0)))^2 + (val(p1(1)) - val(p2(1)))^2) / 5, sqr((val(p3(0)) - val(p2(0))) ^ 2 + (val(p3(1)) - val(p2(1))) ^ 2) / 5)
unRayon = min(unRayon, OOoTep_codageangle / xunit)
end if
ang1 = CalculeAngle(val(p2(0)), val(p2(1)), val(p1(0)), val(p1(1))) * 180 / Pi
ang2 = CalculeAngle(val(p2(0)), val(p2(1)), val(p3(0)), val(p3(1))) * 180 / Pi
if ang1 > ang2 then ang2 = ang2 + 360
if ang2 - ang1 > 180 and sType = TEP_ANGLE and RetourneOption(options, "rentrant") = "" then
ang2 = ang2 - 360
Echange(ang1, ang2)
Echange(p3(0), p1(0))
Echange(p3(1), p1(1))
end if
if RetourneOption(options, "visibilite") = "v" then
if (sType = TEP_ANGLE) And Abs(ang2 - ang1 - 90) < 0.1 then
unTrait = MarqueAngleDroit(CalcAbscisse(val(p2(0))), CalcOrdonnee(val(p2(1))), CalcAbscisse(val(p3(0))), CalcOrdonnee(val(p3(1))), options)
OpaciteTrait(unTrait, RetourneOption(options, "opacite"), RetourneOption(options, "couleur"))
else
If RetourneOption(options, "opacite") = "0" then
unTrait = InsereArcDeCercle(CalcAbscisse(val(p2(0))), CalcOrdonnee(val(p2(1))), ang1 * 100, ang2 * 100, unRayon * xunit, False)
else
unTrait = InsereArcDeCercle(CalcAbscisse(val(p2(0))), CalcOrdonnee(val(p2(1))), ang1 * 100, ang2 * 100, unRayon * xunit, True)
OpaciteTrait(unTrait, RetourneOption(options, "opacite"), RetourneOption(options, "couleur"))
end if
End If
unTrait.LineColor=RetourneCouleur(RetourneOption(options, "couleur"))
StyleTrait(unTrait, RetourneOption(options, "style"))
End if
Sorte(NbObjet) = TEP_ARC
Nom(NbObjet) = unNom
Parametres(NbObjet) = p2(0) & ";" & p2(1) & ";" & trim(str(unRayon)) & ";" & trim(str(ang1)) & ";" & trim(str(ang2))
NbObjet = NbObjet + 1
End Sub
Sub AjouteBarycentre(unNom as String, listeObjets as String, options as String)
Dim lesObjets() as String
Dim p1() as String
Dim tm as Double
Dim x0 as Double
Dim y0 as Double
dim i as integer
ChargeParametre(listeObjets, lesObjets, ",")
tm = 0
x0 = 0
y0 = 0
for i = LBound(lesObjets) to UBound(lesObjets) - 1 step 2
ChargeParametre(Parametres(ChercheObjet(lesObjets(i))), p1, ";")
if ChercheObjet(lesobjets(i + 1)) <> - 1 then lesobjets(i + 1) = parametres(ChercheObjet(lesobjets(i + 1)))
x0 = x0 + val(lesObjets(i + 1)) * val(p1(0))
y0 = y0 + val(lesObjets(i + 1)) * val(p1(1))
tm = tm + val(lesObjets(i + 1))
next i
x0 = x0 / tm
y0 = y0 / tm
AjoutePoint(unNom, trim(str(x0)) & "," & trim(str(y0)), options)
End Sub
Sub AjouteBissectrice(unNom as String, listeObjets as String, options as String)
Dim lesObjets() As String
Dim p1() as String
Dim p2() as String
Dim p3() as String
Dim ang as Double
Dim x0 as string
Dim y0 as string
Dim x1 as string
Dim y1 as string
Dim unTrait as Object
ChargeParametre(listeObjets, lesObjets, ",")
ChargeParametre(Parametres(ChercheObjet(lesObjets(0))), p1, ";")
ChargeParametre(Parametres(ChercheObjet(lesObjets(1))), p2, ";")
ChargeParametre(Parametres(ChercheObjet(lesObjets(2))), p3, ";")
ang = (CalculeAngle(val(p2(0)), val(p2(1)), val(p1(0)), val(p1(1))) + CalculeAngle(val(p2(0)), val(p2(1)), val(p3(0)), val(p3(1)))) / 2
x0 = p2(0)
y0 = p2(1)
x1 = trim(str(val(x0) + 5000 * cos(ang))
y1 = trim(str(val(y0) + 5000 * sin(ang))
if RetourneOption(options, "visibilite") = "v" then
unTrait = TraceDroite(CalcAbscisse(val(x0)), CalcOrdonnee(val(y0)), CalcAbscisse(val(x1)), CalcOrdonnee(val(y1)), xmin, ymin, xmax, ymax, unNom, False, options)
unTrait.LineColor = RetourneOption(options, "couleur")
StyleTrait(unTrait, RetourneOption(options, "style"))
End if
Nom(NbObjet) = unNom
Sorte(NbObjet) = TEP_DROITE
Parametres(NbObjet) = x0 & ";" & y0 & ";" & x1 & ";" & y1
NbObjet = NbObjet + 1
End Sub
Sub AjouteCercle(unNom as string, coordonnees as string, options as string, typeCercle as integer)
dim i, j
dim param() as string
dim p1() as string
dim p2() as string
Dim unTrait as Object
Dim unRayon as Double
ChargeParametre(coordonnees, param, ",")
i = ChercheObjet(param(0))
ChargeParametre(Parametres(i), p1, ";")
select case typeCercle
case TEP_CERCLE, TEP_CERCLEDIA
j = ChercheObjet(param(1))
ChargeParametre(Parametres(j), p2, ";")
unRayon = sqr((val(p1(0)) - val(p2(0)))^2 + (val(p1(1)) - val(p2(1)))^2)
if typeCercle = TEP_CERCLEDIA then
unRayon = unRayon / 2
p1(0) = trim(str((val(p1(0)) + val(p2(0))) / 2))
p1(1) = trim(str((val(p1(1)) + val(p2(1))) / 2))
end if
case TEP_CERCLERAYON
unRayon = val(RetourneVariable(param(1)))
End Select
if RetourneOption(options, "visibilite") = "v" then
unTrait = InsereCercle(CalcAbscisse(val(p1(0))), CalcOrdonnee(val(p1(1))), unRayon * xunit)
unTrait.LineColor = RetourneOption(options, "couleur")
StyleTrait(unTrait, RetourneOption(options, "style"))
OpaciteTrait(unTrait, RetourneOption(options, "opacite"), RetourneOption(options, "couleur"))
end if
Sorte(NbObjet) = TEP_CERCLE
Nom(NbObjet) = unNom
Parametres(NbObjet) = p1(0) & ";" & p1(1) & ";" & trim(str(unRayon))
NbObjet = NbObjet + 1
End Sub
Sub AjouteDistance(unNom As String, listeObjets as String, options as String)
Dim lesObjets() as String
Dim uneDistance as Double
Dim p1() as String
Dim p2() as String
ChargeParametre(listeObjets, lesObjets, ",")
ChargeParametre(Parametres(ChercheObjet(lesObjets(0))), p1, ";")
ChargeParametre(Parametres(ChercheObjet(lesObjets(0))), p2, ";")
uneDistance = sqr((val(p1(0)) - val(p2(0)))^2 + (val(p1(1)) - val(p2(1)))^2)
Nom(NbObjet) = unNom
Sorte(NbObjet) = TEP_VARIABLE
Parametres(NbObjet) = trim(str(uneDistance))
NbObjet = NbObjet + 1
End Sub
Sub AjouteDroite(unNom as string, listeObjets as string, options as string, sType as integer)
dim lesObjets() as string
dim p1() as string
dim p2() as string
dim unTrait as Object
Dim ang as double
Dim x0 as string
Dim y0 as string
Dim x1 as string
Dim y1 as string
dim xint as double
dim yint as double
ChargeParametre(listeObjets, lesObjets, ",")
ChargeParametre(Parametres(ChercheObjet(lesObjets(0))), p1, ";")
ChargeParametre(Parametres(ChercheObjet(lesObjets(1))), p2, ";")
ang = CalculeAngle(val(p2(0)), val(p2(1)), val(p2(2)), val(p2(3)))
x0 = p1(0)
y0 = p1(1)
Select Case sType
case TEP_DROITEPARALLELE
x1 = trim(str(val(p1(0)) + 5 * cos(ang)))
y1 = trim(str(val(p1(1)) + 5 * sin(ang)))
case TEP_DROITEPERPENDICULAIRE
x1 = trim(str(val(p1(0)) - 5 * sin(ang)))
y1 = trim(str(val(p1(1)) + 5 * cos(ang)))
TrouveIntersection(val(p2(0)), val(p2(1)), val(p2(2)), val(p2(3)), val(x0), val(y0), val(x1), val(y1), xint, yint)
If RetourneOption(options, "visibilite") = "v" and RetourneOption(options, "quadrant") <> "0" then
unTrait = MarqueAngleDroit(CalcAbscisse(xint), CalcOrdonnee(yint), CalcAbscisse(val(x1)), CalcOrdonnee(val(y1)), options)
unTrait.LineColor = RetourneOption(options, "couleur")
StyleTrait(unTrait, RetourneOption(options, "style"))
end if
End Select
If RetourneOption(options, "visibilite") = "v" then
unTrait = TraceDroite(CalcAbscisse(val(x0)), CalcOrdonnee(val(y0)), CalcAbscisse(val(x1)), CalcOrdonnee(val(y1)), xmin, ymin, xmax, ymax, unNom, False, options)
unTrait.LineColor = RetourneOption(options, "couleur")
StyleTrait(unTrait, RetourneOption(options, "style"))
End If
Nom(NbObjet) = unNom
Sorte(NbObjet) = TEP_DROITE
Parametres(NbObjet) = x0 & ";" & y0 & ";" & x1 & ";" & y1
NbObjet = NbObjet + 1
End Sub
Sub AjouteTangente(unNom as string, listeObjets as string, options as string)
dim lesObjets() as string
dim p1() as string
dim p2() as string
dim unTrait as Object
Dim ang as double
Dim x0 as single
Dim y0 as single
Dim x1 as single
Dim y1 as single
dim xint as double
dim yint as double
dim a as single, b as single, c as single
ChargeParametre(listeObjets, lesObjets, ",")
a = lesObjets(0)
b = lesObjets(1)
c = lesObjets(2)
if a = 0 then
x0 = xmin
y0 = - c / b
x1 = xmax
y1 = - c / b
end if
if b = 0 then
x0 = - c / a
y0 = ymin
x1 = - c / a
y1 = ymax
end if
if a <> 0 and b <> 0 then
x0 = xmin
y0 = ( - c - a * x0) / b
x1 = xmax
y1 = ( - c - a * x1) / b
end if
x0 = calcAbscisse(x0)
x1 = calcAbscisse(x1)
y0 = calcOrdonnee(y0)
y1 = calcOrdonnee(y1)
If RetourneOption(options, "visibilite") = "v" then
unTrait = TraceDroite(x0, y0, x1, y1, xmin, ymin, xmax, ymax, unNom, False, options)
unTrait.LineColor = RetourneOption(options, "couleur")
StyleTrait(unTrait, RetourneOption(options, "style"))
End If
Nom(NbObjet) = unNom
Sorte(NbObjet) = TEP_DROITE
Parametres(NbObjet) = x0 & ";" & y0 & ";" & x1 & ";" & y1
NbObjet = NbObjet + 1
End Sub
Sub AjouteGroupe(unNom as String, listeObjets as String, options as String)
RemplaceTexte(listeObjets, ",", ";")
Nom(NbObjet) = unNom
Sorte(NbObjet) = TEP_GROUPE
Parametres(NbObjet) = listeObjets
NbObjet = NbObjet + 1
End Sub
Sub AjouteHomothetie(unNom as string, listeObjets as string)
Dim lesObjets() as String
Dim p1() as String
ChargeParametre(listeObjets, lesObjets, ",")
ChargeParametre(Parametres(ChercheObjet(lesObjets(0))), p1, ";")
Nom(NbObjet) = unNom
Sorte(NbObjet) = TEP_HOMOTHETIE
Parametres(NbObjet) = p1(0) & ";" & p1(1) & ";" & RetourneVariable(lesObjets(1))
NbObjet = NbObjet + 1
End Sub
Sub AjouteImage(unNom as String, listeObjets as String, options as String)
Dim param() as string
Dim p2() as string
Dim p1 as String
dim i as integer, j as integer, k as integer, l as integer
Dim unTrait as Object
Dim unRayon as double, ang1 as double, ang2 as Double
ChargeParametre(listeObjets, param, ",")
i = ChercheObjet(param(0))
j = ChercheObjet(param(1))
Select Case Sorte(j)
case TEP_POINT
ImagePoint(i, Parametres(j), p1)
AjoutePoint(unNom, p1, options)
case TEP_DROITE, TEP_SEGMENT, TEP_DEMIDROITE, TEP_VECTEUR, TEP_DROITEEQR, TEP_DROITEEQ, TEP_DROITEV, TEP_DROITEANGLE
ImageDroite(i, Parametres(j), p1)
ChargeParametre(p1, p2, ",")
if RetourneOption(options, "visibilite") = "v" then
Select Case Sorte(j)
case TEP_SEGMENT
unTrait = InsereLigne(CalcAbscisse(val(p2(0))), CalcOrdonnee(val(p2(1))), CalcAbscisse(val(p2(2))), CalcOrdonnee(val(p2(3))))
case TEP_DROITE, TEP_DROITEEQR, TEP_DROITEEQ, TEP_DROITEV, TEP_DROITEANGLE
unTrait = TraceDroite(CalcAbscisse(val(p2(0))), CalcOrdonnee(val(p2(1))), CalcAbscisse(val(p2(2))), CalcOrdonnee(val(p2(3))), xmin, ymin, xmax, ymax, unNom, False, options)
case TEP_DEMIDROITE
unTrait = TraceDroite(CalcAbscisse(val(p2(0))), CalcOrdonnee(val(p2(1))), CalcAbscisse(val(p2(2))), CalcOrdonnee(val(p2(3))), xmin, ymin, xmax, ymax, unNom, True, options)
case TEP_VECTEUR
unTrait = InsereVecteur(CalcAbscisse(val(p2(0))), CalcOrdonnee(val(p2(1))), CalcAbscisse(val(p2(2))), CalcOrdonnee(val(p2(3))), RetourneOption(options, "couleur"))
End Select
unTrait.LineColor = RetourneOption(options, "couleur")
StyleTrait(unTrait, RetourneOption(options, "style"))
End if
Nom(NbObjet) = unNom
Sorte(NbObjet) = Sorte(j)
Parametres(NbObjet) = p2(0) & ";" & p2(1) & ";" & p2(2) & ";" & p2(3)
NbObjet = NbObjet + 1
case TEP_CERCLE
ChargeParametre(Parametres(j), p2, ";")
unRayon = val(p2(2))
unRayon = ImageRayon(i, unRayon)
ImagePoint(i, p2(0) & ";" & p2(1), p1)
ChargeParametre(p1, p2, ",")
if RetourneOption(options, "visibilite") = "v" then
unTrait = InsereCercle(CalcAbscisse(val(p2(0))), CalcOrdonnee(val(p2(1))), unRayon * xunit)
unTrait.LineColor = RetourneOption(options, "couleur")
StyleTrait(unTrait, RetourneOption(options, "style"))
OpaciteTrait(unTrait, RetourneOption(options, "opacite"), RetourneOption(options, "couleur"))
End if
Sorte(NbObjet) = TEP_CERCLE
Nom(NbObjet) = unNom
Parametres(NbObjet) = p2(0) & ";" & p2(1) & ";" & trim(str(unRayon))
NbObjet = NbObjet + 1
case TEP_ARC
ImageArc(i, Parametres(j), p1)
ChargeParametre(p1, p2, ";")
unRayon = val(p2(2))
ang1 = val(p2(3))
ang2 = val(p2(4))
if RetourneOption(options, "visibilite") = "v" then
If RetourneOption(options, "opacite") = "0" then
unTrait = InsereArcDeCercle(CalcAbscisse(val(p2(0))), CalcOrdonnee(val(p2(1))), ang1 * 100, ang2 * 100, unRayon * xunit, False)
else
unTrait = InsereArcDeCercle(CalcAbscisse(val(p2(0))), CalcOrdonnee(val(p2(1))), ang1 * 100, ang2 * 100, unRayon * xunit, True)
OpaciteTrait(unTrait, RetourneOption(options, "opacite"), RetourneOption(options, "couleur"))
end if
unTrait.LineColor=RetourneCouleur(RetourneOption(options, "couleur"))
StyleTrait(unTrait, RetourneOption(options, "style"))
End if
Sorte(NbObjet) = TEP_ARC
Nom(NbObjet) = unNom
Parametres(NbObjet) = p1
NbObjet = NbObjet + 1
case TEP_GROUPE
ChargeParametre(Parametres(j), param, ";")
for k = LBound(param) to UBound(param)
l = ChercheObjet(param(k))
AjouteImage(unNom & "." & Nom(l), Nom(i) & "," & Nom(l), options)
next k
End Select
End Sub
Sub ImageArc(i as integer, arc1 as string, arc2 as string)
Dim p2 as String
Dim p1 as string
Dim p0 as String
Dim x0 as single, y0 as single, x1 as single, y1 as single, x2 as single, y2 as single
Dim unRayon, ang1, ang2
ChargeParametre(arc1, p2, ";")
unRayon = val(p2(2))
ang1 = val(p2(3))
ang2 = val(p2(4))
x0 = val(p2(0))
y0 = val(p2(1))
x1 = x0 + unRayon * cos( ang1 * Pi / 180)
y1 = y0 + unRayon * sin( ang1 * Pi / 180)
x2 = x0 + unRayon * cos( ang2 * Pi / 180)
y2 = y0 + unRayon * sin( ang2 * Pi / 180)
ImagePoint(i, trim(str(x2)) & ";" & trim(str(y2)), p0)
ChargeParametre(p0, p1, ",")
x2 = val(p1(0))
y2 = val(p1(1))
ImagePoint(i, trim(str(x1)) & ";" & trim(str(y1)), p0)
ChargeParametre(p0, p1, ",")
x1 = val(p1(0))
y1 = val(p1(1))
ImagePoint(i, trim(str(x0)) & ";" & trim(str(y0)), p0)
ChargeParametre(p0, p1, ",")
x0 = val(p1(0))
y0 = val(p1(1))
unRayon = sqr((x0 - x1)^2 + (y0 - y1)^2)
ang1 = CalculeAngle(x0, y0, x1, y1) * 180 / Pi
ang2 = CalculeAngle(x0, y0, x2, y2) * 180 / Pi
if ang1 > ang2 then ang2 = ang2 + 360
arc2 = trim(str(x0)) & ";" & trim(str(y0)) & ";" & trim(str(unRayon)) & ";" & trim(str(ang1)) & ";" & trim(str(ang2))
End Sub
Sub AjouteIntersection(unNom as String, listeObjets as String, options as String, lescoords as String)
AjoutePoint(unNom, lescoords, options)
End Sub
Sub AjoutePointSur(unNom as string, listeObjets as string, options as string, lesCoords as String)
AjoutePoint(unNom, lescoords, options)
End Sub
sub AjouteMediatrice(unNom as string, coordonnees as string, options as string)
dim x0 as string
Dim y0 as String
dim x1 as string
Dim y1 as String
dim param() as string
Dim ang as Double
Dim p1() as String
Dim p2() as String
Dim unTrait as Object
Dim visibiliteSegment as String
ChargeParametre(coordonnees, param(), ",")
if Sorte(Chercheobjet(param(0))) = TEP_SEGMENT then
ChargeParametre(Parametres(ChercheObjet(param(0))), p1, ";")
ChargeParametre(Parametres(ChercheObjet(param(0))), p2, ";")
ang = CalculeAngle(val(p1(0)), val(p1(1)), val(p1(2)), val(p1(3))) + Pi / 2
x0 = trim(str((val(p1(0)) + val(p1(2))) / 2))
y0 = trim(str((val(p1(1)) + val(p1(3))) / 2))
p2(0) = p1(2)
p2(1) = p1(3)
visibiliteSegment = p1(4)
else
ChargeParametre(Parametres(ChercheObjet(param(0))), p1, ";")
ChargeParametre(Parametres(ChercheObjet(param(1))), p2, ";")
ang = CalculeAngle(val(p1(0)), val(p1(1)), val(p2(0)), val(p2(1))) + Pi / 2
x0 = trim(str((val(p1(0)) + val(p2(0))) / 2))
y0 = trim(str((val(p1(1)) + val(p2(1))) / 2))
visibiliteSegment = ""
end if
x1 = trim(str(val(x0) + 500 * cos(ang)))
y1 = trim(str(val(y0) + 500 * sin(ang)))
if RetourneOption(options, "visibilite") = "v" then
if Sorte(Chercheobjet(param(0))) = TEP_SEGMENT then
If RetourneOption(options, "quadrant") <> "0" and RetourneOption(visibiliteSegment, "visibilite") = "v" then
unTrait = MarqueAngleDroit(CalcAbscisse(val(x0)), CalcOrdonnee(val(y0)), CalcAbscisse(val(x1)), CalcOrdonnee(val(y1)), options)
unTrait.LineColor=RetourneOption(options,"couleur")
StyleTrait(unTrait, RetourneOption(options,"style"))
end If
if RetourneOption(options, "code") <> "" then
CodeLongueur(CalcAbscisse(val(x0)), CalcOrdonnee(val(y0)), CalcAbscisse(val(p2(0))), CalcOrdonnee(val(p2(1))), RetourneOption(options, "code"), options)
CodeLongueur(CalcAbscisse(val(x0)), CalcOrdonnee(val(y0)), CalcAbscisse(val(p1(0))), CalcOrdonnee(val(p1(1))), RetourneOption(options, "code"), options)
End if
End If
unTrait = TraceDroite(CalcAbscisse(val(x0)), CalcOrdonnee(val(y0)), CalcAbscisse(val(x1)), CalcOrdonnee(val(y1)), xmin, ymin, xmax, ymax, unNom, False, options)
unTrait.LineColor = RetourneOption(options, "couleur")
StyleTrait(unTrait, RetourneOption(options, "style"))
End If
Nom(NbObjet) = unNom
Sorte(NbObjet) = TEP_DROITE
Parametres(NbObjet) = x0 & ";" & y0 & ";" & x1 & ";" & y1
NbObjet = NbObjet + 1
end sub
Sub AjouteMesureArc(unNom as String, listeObjets as String, options as String)
Dim lesObjets() As String
Dim p1() as String
ChargeParametre(listeObjets, lesObjets, ",")
if Sorte(ChercheObjet(lesObjets(0))) = TEP_ARC then
ChargeParametre(Parametres(ChercheObjet(lesObjets(0))), p1, ";")
else
AjouteArc("tempo", listeObjets, "i", TEP_ARC)
NbObjet = NbObjet - 1
ChargeParametre(Parametres(NbObjet), p1, ";")
end if
AjouteVariable(unNom, trim(str(val(p1(2)) * abs(val(p1(4)) - val(p1(3))) * Pi / 180)), options)
End Sub
sub AjouteMilieu(unNom as string, coordonnees as string, options as string)
dim x0 as string
Dim y0 as String
dim param() as string
Dim p1() as String
Dim p2() as String
ChargeParametre(coordonnees, param(), ",")
if Sorte(Chercheobjet(param(0))) = TEP_SEGMENT then
ChargeParametre(Parametres(ChercheObjet(param(0))), p1, ";")
ChargeParametre(Parametres(ChercheObjet(param(0))), p2, ";")
p2(0) = p1(2)
p2(1) = p1(3)
else
ChargeParametre(Parametres(ChercheObjet(param(0))), p1, ";")
ChargeParametre(Parametres(ChercheObjet(param(1))), p2, ";")
end if
x0 = trim(str((val(p1(0)) + val(p2(0))) / 2))
y0 = trim(str((val(p1(1)) + val(p2(1))) / 2))
AjoutePoint(unNom, x0 & "," & y0, options)
If RetourneOption(options,"visibilite")="v" then
Dim unCodage as string
unCodage=RetourneOption(options,"code")
if unCodage<>"" then
CodeLongueur(CalcAbscisse(val(p1(0))),CalcOrdonnee(val(p1(1))),CalcAbscisse(val(x0)),CalcOrdonnee(val(y0)),unCodage,options)
CodeLongueur(CalcAbscisse(val(x0)),CalcOrdonnee(val(y0)),CalcAbscisse(val(p2(0))),CalcOrdonnee(val(p2(1))),unCodage,options)
end if
end if
End Sub
Sub AjoutePerimetre(unNom As String, listeObjets as String, options as String)
Dim lesObjets() as String
Dim unPerimetre as Double
Dim p1() as String
Dim p2() as String
Dim p3() as String
ChargeParametre(listeObjets, lesObjets, ",")
if Sorte(ChercheObjet(lesObjets(0))) = TEP_CERCLE then
ChargeParametre(Parametres(ChercheObjet(lesObjets(0))), p1, ";")
unPerimetre = 2 * Pi * val(p1(2))
Else
if Sorte(ChercheObjet(lesObjets(0))) = TEP_POLYGONE then
ChargeParametre(Parametres(ChercheObjet(lesObjets(0))), lesObjets, ";"
end if
unPerimetre = 0
for i = LBound(lesObjets) to UBound(lesObjets)
ChargeParametre(Parametres(ChercheObjet(lesObjets(i))), p1, ";")
if i = UBound(lesObjets) then
ChargeParametre(Parametres(ChercheObjet(lesObjets(0))), p2, ";")
else
ChargeParametre(Parametres(ChercheObjet(lesObjets(i + 1))), p2, ";")
end if
unPerimetre = unPerimetre + sqr((val(p1(0)) - val(p2(0)))^2 + (val(p1(1)) - val(p2(1)))^2)
next i
end if
Nom(NbObjet) = unNom
Sorte(NbObjet) = TEP_VARIABLE
Parametres(NbObjet) = trim(str(unPerimetre))
NbObjet = NbObjet + 1
End Sub
Sub AjouteFonction(unNom as String, listeCoord as String, options as String)
Dim lesPoints() as String
dim secArray() as Single
dim triArray() as single
Dim np as single, i as Integer
Dim j as Integer, k as Integer
Dim unPolygone as Object
Dim cestbon as Boolean
dim xint as single
dim yint as single
if listeCoord = "" then
Sorte(NbObjet) = TEP_FONCTION
Nom(NbObjet) = unNom
Parametres(NbObjet) = options
NbObjet = NbObjet + 1
else
' options = Parametres(ChercheObjet(unNom))
RemplaceTexte listeCoord, chr(13), ""
RemplaceTexte listeCoord, chr(10), ""
ChargeParametre(listeCoord, lesPoints, ";")
np = ubound(lesPoints()) / 2
ReDim secArray(0 to np - 1, 0 to 1) as single
j = 0
for i = 0 to np - 1
if i = np - 1 then
cestbon = True
else
if (lesPoints(2 * i + 1) = "123456789" and lesPoints(2 * i + 2) = "123456789") then
cestbon = True
else
if (val(lesPoints(2 * i + 1)) < xmin or val(lesPoints(2 * i + 1)) > xmax or val(lesPoints(2 * i + 2)) < ymin or val(lesPoints(2 * i + 2)) > ymax) then
cestbon = True
if j > 0 then
if TrouveIntersectionSegment(secArray(j - 1, 0), secArray(j - 1, 1), calcAbscisse(val(lesPoints(2 * i + 1))), calcOrdonnee(val(lesPoints(2 * i + 2))), xint, yint) then
secArray(j, 0) = xint
secArray(j, 1) = yint
j = j + 1
end if
end if
end if
if (val(lesPoints(2 * i + 1)) >= xmin and val(lesPoints(2 * i + 1)) <= xmax and val(lesPoints(2 * i + 2)) >= ymin and val(lesPoints(2 * i + 2)) <= ymax) then
if j = 0 and i > 0 then
if TrouveIntersectionSegment(calcAbscisse(val(lesPoints(2 * i - 1))), calcOrdonnee(val(lesPoints(2 * i))), calcAbscisse(val(lesPoints(2 * i + 1))), calcOrdonnee(val(lesPoints(2 * i + 2))), xint, yint) then
secArray(j, 0) = xint
secArray(j, 1) = yint
j = j + 1
end if
end if
end if
end if
end If
if cestbon then
if j > 0 then
ReDim triArray(0 to j - 1, 0 to 1) as single
for k = 0 to j - 1
triArray(k, 0) = secArray(k, 0)
triArray(k, 1) = secArray(k, 1)
next k
if RetourneOption(options, "visibilite") = "v" then
unPolygone = InsereCourbe(triArray(), j)
unPolygone.LineColor = val(RetourneOption(options, "couleur"))
StyleTrait(unPolygone, RetourneOption(options, "style"))
End If
end if
j = 0
cestbon = False
else
secArray(j, 0) = CalcAbscisse(val(lesPoints(2 * i + 1)))
secArray(j, 1) = CalcOrdonnee(val(lesPoints(2 * i + 2)))
j = j + 1
end if
next i
end if
End Sub
sub AjoutePoint(unNom as string, coordonnees as string, options as string)
dim x0 as single, y0 as single
dim param() as string
Dim p1() as String
dim uneCouleur as long
Dim unTrait as Object
dim unTexte as Object
uneCouleur = RetourneCouleur(RetourneOption(options, "couleur"))
ChargeParametre(coordonnees, param(), ",")
ChargeParametre(coordonnees, p1(), ",")
param(0) = RetourneVariable(param(0))
param(1) = RetourneVariable(param(1))
p1(0) = param(0)
p1(1) = param(1)
x0 = CalcAbscisse(val(param(0)))
y0 = CalcOrdonnee(val(param(1)))
Sorte(NbObjet) = TEP_POINT
Nom(NbObjet) = unNom
Parametres(NbObjet) = param(0) & ";" & param(1)
NbObjet = NbObjet + 1
if RetourneOption(options, "visibilite") = "v" then
Select case RetourneOption(options, "pointille")
case "p1"
unTrait = InsereLigne(x0, y0, calcAbscisse(0), y0)
StyleTrait(unTrait, "7")
unTrait = InsereLigne(x0, y0, x0, calcOrdonnee(0))
StyleTrait(unTrait, "7")
End Select
Select case RetourneOption(options, "coord")
case "coord"
InsereTexte(param(0), x0, calcOrdonnee(0) + 100, 10, "")
InsereTexte(param(1), calcAbscisse(0), y0, 10, "")
case "coordx"
InsereTexte(param(0), x0, calcOrdonnee(0) + 100, 10, "")
case "coordy"
InsereTexte(param(1), calcAbscisse(0), y0, 10, "")
End Select
Dim pGroupe As object
Select case RetourneOption(options, "point")
case "croix0"
pGroupe = InitialiseGroupe()
unTrait = InsereLigne(x0 - OOoTep_croix0, y0 - OOoTep_croix0, x0 + OOoTep_croix0, y0 + OOoTep_croix0, pGroupe)
unTrait.LineColor = uneCouleur
StyleTrait(unTrait, RetourneOption(options, "style"))
unTrait = InsereLigne(x0 - OOoTep_croix0, y0 + OOoTep_croix0, x0 + OOoTep_croix0, y0 - OOoTep_croix0, pGroupe)
unTrait.LineColor = uneCouleur
StyleTrait(unTrait, RetourneOption(options, "style"))
pGroupe = GroupeObjet(pGroupe)
oGroupeDessin.add(pGroupe)
case "croix1"
pGroupe = InitialiseGroupe()
unTrait = InsereLigne(x0 - OOoTep_croix1, y0 - OOoTep_croix1, x0 + OOoTep_croix1, y0 + OOoTep_croix1, pGroupe)
unTrait.LineColor = uneCouleur
StyleTrait(unTrait, RetourneOption(options, "style"))
unTrait = InsereLigne(x0 - OOoTep_croix1, y0 + OOoTep_croix1, x0 + OOoTep_croix1, y0 - OOoTep_croix1, pGroupe)
unTrait.LineColor = uneCouleur
StyleTrait(unTrait, RetourneOption(options, "style"))
pGroupe = GroupeObjet(pGroupe)
oGroupeDessin.add(pGroupe)
case "croix2"
pGroupe = InitialiseGroupe()
unTrait = InsereLigne(x0 - OOoTep_croix2, y0 - OOoTep_croix2, x0 + OOoTep_croix2, y0 + OOoTep_croix2, pGroupe)
unTrait.LineColor = uneCouleur
StyleTrait(unTrait, RetourneOption(options, "style"))
unTrait = InsereLigne(x0 - OOoTep_croix2, y0 + OOoTep_croix2, x0 + OOoTep_croix2, y0 - OOoTep_croix2, pGroupe)
unTrait.LineColor = uneCouleur
StyleTrait(unTrait, RetourneOption(options, "style"))
pGroupe = GroupeObjet(pGroupe)
oGroupeDessin.add(pGroupe)
case "croix3"
pGroupe = InitialiseGroupe()
unTrait = InsereLigne(x0 - OOoTep_croix3, y0 - OOoTep_croix3, x0 + OOoTep_croix3, y0 + OOoTep_croix3, pGroupe)
unTrait.LineColor = uneCouleur
StyleTrait(unTrait, RetourneOption(options, "style"))
unTrait = InsereLigne(x0 - OOoTep_croix3, y0 + OOoTep_croix3, x0 + OOoTep_croix3, y0 - OOoTep_croix3, pGroupe)
unTrait.LineColor = uneCouleur
StyleTrait(unTrait, RetourneOption(options, "style"))
pGroupe = GroupeObjet(pGroupe)
oGroupeDessin.add(pGroupe)
case "rond1"
unTrait = InsereCercle(x0, y0, OOoTep_rond1)
unTrait.LineColor = uneCouleur
unTrait.FillColor = uneCouleur
case "rond2"
unTrait = InsereCercle(x0, y0, OOoTep_rond2)
unTrait.LineColor = uneCouleur
unTrait.FillColor = uneCouleur
case "rond3"
unTrait = InsereCercle(x0, y0, OOoTep_rond3)
unTrait.LineColor = uneCouleur
unTrait.FillColor = uneCouleur
end Select
ChargeParametre(RetourneOption(options, "position"), param(), ";")
x0 = val(p1(0)) + val(param(0))
y0 = val(p1(1)) - val(param(1))
if RetourneOption(options, "nom") = "nom" then
Dim uneTaille as integer
uneTaille = val(OOoTep_taillepolice) + val(RetourneOption(options, "taille"))
unTexte = InsereTexte(unNom, CalcAbscisse(x0), CalcOrdonnee(y0), uneTaille)
' CouleurTexte(unTexte, uneCouleur)
PoliceTexte(unTexte, RetourneOption(Options, "police"))
end if
end if
end sub
Sub AjoutePolygone(unNom as string, listePoints as String, options as string)
dim lesPoints() as string
dim p1() as string
dim unPolygone as Object
dim triArray() as single
dim i, np
np = ChargeParametre(listePoints, lesPoints, ",")
ReDim triArray(0 to np - 1, 0 to 1) as single
for i = 0 to np - 1
ChargeParametre(Parametres(ChercheObjet(lesPoints(i))), p1, ";")
triArray(i, 0) = CalcAbscisse(val(p1(0)))
triArray(i, 1) = CalcOrdonnee(val(p1(1)))
next i
if RetourneOption(options, "visibilite") = "v" then
unPolygone = InserePolygoneB(triArray(), np)
unPolygone.LineColor = val(RetourneOption(options, "couleur"))
StyleTrait(unPolygone, RetourneOption(options, "style"))
OpaciteTrait(unPolygone, RetourneOption(options, "opacite"), RetourneOption(options, "couleur"))
End If
RemplaceTexte(listePoints, ",", ";")
Nom(NbObjet) = unNom
Sorte(NbObjet) = TEP_POLYGONE
Parametres(NbObjet) = listePoints
NbObjet = NbObjet + 1
End Sub
Sub AjouteProjete(unNom as String, listeObjets as String, options as String)
dim x0 as double
Dim y0 as double
dim lesObjets() as string
Dim p1() as String
Dim p2() as String
Dim p3() as String
Dim ang as Double
Dim u, num, den
Dim x1,y1,x2,y2,x3,y3
ChargeParametre(listeObjets, lesObjets, ",")
ChargeParametre(Parametres(ChercheObjet(lesObjets(0))), p1, ";")
ChargeParametre(Parametres(ChercheObjet(lesObjets(1))), p2, ";")
' if UBound(lesObjets) = 2 then
' ChargeParametre(Parametres(ChercheObjet(lesObjets(2))), p3, ";")
' ang = CalculeAngle(val(p3(0)), val(p3(1)), val(p3(2)), val(p3(3)))
' else
' ang = CalculeAngle(val(p2(0)), val(p2(1)), val(p2(2)), val(p2(3))) + Pi / 2
' end if
' TrouveIntersection(val(p1(0)), val(p1(1)), val(p1(0)) + 500 * cos(ang), val(p1(1)) + 500 * sin(ang), val(p2(0)), val(p2(1)), val(p2(2)), val(p2(3)), x0, y0)
x1 = val(p2(0))
y1 = val(p2(1))
x2 = val(p2(2))
y2 = val(p2(3))
x3 = val(p1(0))
y3 = val(p1(1))
num = (x3 - x1) * (x2 - x1) + (y3 - y1) * (y2 - y1)
den = (x2 - x1) ^ 2 + (y2 - y1) ^ 2
u=num/den
x0 = x1 + u * (x2 - x1)
y0 = y1 + u * (y2 - y1)
AjoutePoint(unNom, trim(str(x0)) & "," & trim(str(y0)), options)
End Sub
Sub StylePolice(unTrait as Object, tp as integer, sp as integer)
unTrait.Text.CharHeight = tp
unTrait.Text.CharFontName = OOoTep_nompolice
select case sp
case 0
unTrait.Text.CharWeight = com.sun.star.awt.FontWeight.NORMAL
unTrait.Text.CharPosture = com.sun.star.awt.FontSlant.NONE
case 2
unTrait.Text.CharWeight = com.sun.star.awt.FontWeight.BOLD
unTrait.Text.CharPosture = com.sun.star.awt.FontSlant.NONE
case 1
unTrait.Text.CharWeight = com.sun.star.awt.FontWeight.NORMAL
unTrait.Text.CharPosture = com.sun.star.awt.FontSlant.ITALIC
case 3
unTrait.Text.CharWeight = com.sun.star.awt.FontWeight.BOLD
unTrait.Text.CharPosture = com.sun.star.awt.FontSlant.ITALIC
End select
End Sub
sub AjouteRepere(xorig, yorig, xunit, yunit, pasx, pasy, options)
dim i, j
Dim tp as Integer
dim sp as integer
Dim unTrait as Object
Dim nt, axex as Boolean, axey as Boolean
Dim n as Integer
Dim axev as Boolean
dim cr as String
axev = (RetourneOption(options, "visibilite") = "v")
if axev or trame or grille then
tp = val(RetourneOption(options, "tprepere"))
sp = val(RetourneOption(options, "sprepere"))
cr = RetourneOption(options, "crepere")
axex = (ymin < 0 and ymax > 0)
axey = (xmin < 0 and xmax > 0)
nt = val(RetourneOption(options, "grepere"))
for i = int(xmin / pasx) + 1 to int(xmax / pasx)
if trame and (i <> 0 or not axev) then
unTrait = InsereLigne(calcAbscisse(i * pasx), calcOrdonnee(ymax), calcAbscisse(i * pasx), calcOrdonnee(ymin))
unTrait.LineColor = RetourneCouleur("grisclair")
end if
if grille and i <> 0 then
for j = int(ymin / pasy) + 1 to int(ymax / pasy)
if j <> 0 or not axev then
unTrait = InsereCercle(calcAbscisse(i * pasx), calcOrdonnee(j * pasy), 25)
unTrait.LineColor = RetourneCouleur("noir")
OpaciteTrait(unTrait, "100", RetourneCouleur("noir"))
end if
next j
end if
if axex and axev and i <> 0 then
unTrait = InsereLigne(calcAbscisse(i * pasx), calcOrdonnee(0) - MIif((i mod nt) = 0, 200, 100), calcAbscisse(i * pasx), calcOrdonnee(0) + MIif((i mod nt) = 0, 200, 100))
unTrait.LineColor = RetourneOption(options, "couleur")
' if (i mod nt) = 0 then InsereTexte(trim(str(i*pasx)), calcAbscisse(i*pasx), calcOrdonnee(0), tp, sp, cr, AL_CENTRE, AL_HAUT)
end if
Next I
for i = int(ymin / pasy) + 1 to int(ymax / pasy)
if trame and (i <> 0 or not axev) then
unTrait = InsereLigne(calcAbscisse(xmin), calcOrdonnee(i * pasy), calcAbscisse(xmax), calcOrdonnee(i * pasy))
unTrait.LineColor = RetourneCouleur("grisclair")
End if
if axey and axev and i <> 0 then
unTrait = InsereLigne(calcAbscisse(0) - MIif((i mod nt) = 0, 200, 100), calcOrdonnee(i * pasy), calcAbscisse(0) + MIif((i mod nt) = 0, 200, 100), calcOrdonnee(i * pasy))
unTrait.LineColor = RetourneOption(options, "couleur")
' if (i mod nt) = 0 then InsereTexte(trim(str(i*pasy)), calcAbscisse(0), calcOrdonnee(i*pasy), tp, sp, cr, AL_DROITE, AL_CENTRE)
end if
next i
if axex and axev then InsereVecteur(calcAbscisse(xmin), calcOrdonnee(0), calcAbscisse(xmax), calcOrdonnee(0), RetourneOption(options, "couleur"))
if axey and axev then InsereVecteur(calcAbscisse(0), calcOrdonnee(ymin), calcAbscisse(0), calcOrdonnee(ymax), RetourneOption(options, "couleur"))
if axex and axey and axev then InsereTexte("0", calcAbscisse(0), calcOrdonnee(0), tp, sp, cr, AL_DROITE, AL_HAUT)
for i = int(xmin / pasx) + 1 to int(xmax / pasx)
if axex and axev and i <> 0 then
if (i mod nt) = 0 then InsereTexte(trim(str(i * pasx)), calcAbscisse(i * pasx), calcOrdonnee(0), tp, sp, cr, AL_CENTRE, AL_HAUT)
end if
Next I
for i = int(ymin / pasy) + 1 to int(ymax / pasy)
if axey and axev and i <> 0 then
if (i mod nt) = 0 then InsereTexte(trim(str(i * pasy)), calcAbscisse(0), calcOrdonnee(i * pasy), tp, sp, cr, AL_DROITE, AL_CENTRE)
end if
next i
End if
end sub
Sub AjouteRotation(unNom as string, listeObjets as string)
Dim lesObjets() as String
Dim p1() as String
ChargeParametre(listeObjets, lesObjets, ",")
ChargeParametre(Parametres(ChercheObjet(lesObjets(0))), p1, ";")
Nom(NbObjet) = unNom
Sorte(NbObjet) = TEP_ROTATION
Parametres(NbObjet) = p1(0) & ";" & p1(1) & ";" & RetourneVariable(lesObjets(1))
NbObjet = NbObjet + 1
End Sub
Sub AjouteSegment(unNom as string, listePoints as string, options as string, sType as integer)
Dim lesPoints() as string
Dim p1() as string
Dim p2() as string
Dim unTrait as Object
Dim a as Double
Dim b as Double
Dim c as Double
ChargeParametre(listePoints, lesPoints, ",")
select case sType
case TEP_DROITEANGLE
a = Evalue(lesPoints(2)) * Miif(angle_en_radian, 1, Pi / 180)
if RetourneOption(options, "sens") <> "indirect" Then a = - a
ChargeParametre(Parametres(ChercheObjet(lesPoints(0))), p1, ";")
ChargeParametre(Parametres(ChercheObjet(lesPoints(1))), p2, ";")
a = a + CalculeAngle(val(p2(0)), val(p2(1)), val(p2(2)), val(p2(3)))
p2(0) = trim(str(val(p1(0)) + 100 * cos(a)))
p2(1) = trim(str(val(p1(1)) - 100 * sin(a)))
case TEP_DROITEEQR
a = Evalue(lesPoints(0))
b = Evalue(lesPoints(1))
ChargeParametre("0;" & trim(str(b)), p1, ";")
ChargeParametre("1;" & trim(str(a + b)), p2, ";")
case TEP_DROITEEQ
a = Evalue(lesPoints(0))
b = Evalue(lesPoints(1))
c = Evalue(lesPoints(2))
if a = 0 then
ChargeParametre("0;" & trim(str( - c / b)), p1, ";")
ChargeParametre("1;" & trim(str( - c / b)), p2, ";")
else
if b = 0 then
ChargeParametre(trim(str( - c / a)) & ";0" , p1, ";")
ChargeParametre(trim(str( - c / a)) & ";1" , p2, ";")
else
ChargeParametre("0;" & trim(str( - c / b)), p1, ";")
ChargeParametre("1;" & trim(str(( - a - c) / b)), p2, ";")
end if
end if
case TEP_DROITEV
ChargeParametre(Parametres(ChercheObjet(lesPoints(0))), p1, ";")
ChargeParametre(Parametres(ChercheObjet(lesPoints(1))), p2, ";")
p2(0) = trim(str(val(p1(0)) + val(p2(2)) - val(p2(0)))
p2(1) = trim(str(val(p1(1)) + val(p2(3)) - val(p2(1)))
case else
ChargeParametre(Parametres(ChercheObjet(lesPoints(0))), p1, ";")
ChargeParametre(Parametres(ChercheObjet(lesPoints(1))), p2, ";")
end select
if RetourneOption(options, "visibilite") = "v" then
Select Case sType
case TEP_SEGMENT
unTrait = InsereLigne(CalcAbscisse(val(p1(0))), CalcOrdonnee(val(p1(1))), CalcAbscisse(val(p2(0))), CalcOrdonnee(val(p2(1))))
Dim unCodage as String
unCodage = RetourneOption(options, "code")
if unCodage <> "" then
CodeLongueur(CalcAbscisse(val(p1(0))), CalcOrdonnee(val(p1(1))), CalcAbscisse(val(p2(0))), CalcOrdonnee(val(p2(1))), unCodage, options)
End if
case TEP_DROITE, TEP_DROITEEQR, TEP_DROITEEQ, TEP_DROITEV, TEP_DROITEANGLE
unTrait = TraceDroite(CalcAbscisse(val(p1(0))), CalcOrdonnee(val(p1(1))), CalcAbscisse(val(p2(0))), CalcOrdonnee(val(p2(1))), xmin, ymin, xmax, ymax, unNom, False, options)
case TEP_DEMIDROITE
unTrait = TraceDroite(CalcAbscisse(val(p1(0))), CalcOrdonnee(val(p1(1))), CalcAbscisse(val(p2(0))), CalcOrdonnee(val(p2(1))), xmin, ymin, xmax, ymax, unNom, True, options)
case TEP_VECTEUR
unTrait = InsereVecteur(CalcAbscisse(val(p1(0))), CalcOrdonnee(val(p1(1))), CalcAbscisse(val(p2(0))), CalcOrdonnee(val(p2(1))), RetourneOption(options, "couleur"))
End Select
unTrait.LineColor = RetourneOption(options, "couleur")
StyleTrait(unTrait, RetourneOption(options, "style"))
End If
Nom(NbObjet) = unNom
Sorte(NbObjet) = sType
Parametres(NbObjet) = p1(0) & ";" & p1(1) & ";" & p2(0) & ";" & p2(1) & ";" & MIif(options="", "v", options)
NbObjet = NbObjet + 1
End Sub
Sub AjouteSegmentLong(unNom as string, listePoints as string, options as string)
Dim lesPoints() as string
Dim p1() as string
Dim p2() as string
Dim unTrait as Object
Dim a as Double
Dim b as Double
Dim c as Double
Dim l as single
Dim i, j, k
ChargeParametre(listePoints, lesPoints, ",")
l = val(RetourneVariable(lesPoints(2)))
i = ChercheObjet(lesPoints(0))
if i <> - 1 then
ChargeParametre(Parametres(i), p1, ";")
else
ChargeParametre("0;0", p1, ";")
End if
ChargeParametre("0;0", p2, ";")
p2(0) = Trim(Str(val(p1(0)) + l))
' RemplacePointVirgule(p2(0))
p2(1) = p1(1)
AjoutePoint(lesPoints(1), p2(0) & "," & p2(1), options)
if RetourneOption(options, "visibilite") = "v" then
unTrait = InsereLigne(CalcAbscisse(val(p1(0))), CalcOrdonnee(val(p1(1))), CalcAbscisse(val(p2(0))), CalcOrdonnee(val(p2(1))))
Dim unCodage as String
unCodage = RetourneOption(options, "code")
if unCodage <> "" then
CodeLongueur(CalcAbscisse(val(p1(0))), CalcOrdonnee(val(p1(1))), CalcAbscisse(val(p2(0))), CalcOrdonnee(val(p2(1))), unCodage, options)
End if
unTrait.LineColor = RetourneOption(options, "couleur")
StyleTrait(unTrait, RetourneOption(options, "style"))
End If
Nom(NbObjet) = unNom
Sorte(NbObjet) = TEP_SEGMENT
Parametres(NbObjet) = p1(0) & ";" & p1(1) & ";" & p2(0) & ";" & p2(1)
NbObjet = NbObjet + 1
End Sub
Sub AjouteSimilitude(unNom as String, listeObjets as String)
Dim lesObjets() as String
Dim p1() as String
ChargeParametre(listeObjets, lesObjets, ",")
ChargeParametre(Parametres(ChercheObjet(lesObjets(0))), p1, ";")
Nom(NbObjet) = unNom
Sorte(NbObjet) = TEP_SIMILITUDE
Parametres(NbObjet) = p1(0) & ";" & p1(1) & ";" & RetourneVariable(lesObjets(1)) & ";" & RetourneVariable(lesObjets(2))
NbObjet = NbObjet + 1
End Sub
Sub AjouteSymetrie(unNom as String, unObjet as string)
Dim i as Integer
i = ChercheObjet(unObjet)
if Sorte(i) = TEP_POINT then
Sorte(NbObjet) = TEP_SYMETRIQUEPOINT
else
Sorte(NbObjet) = TEP_SYMETRIQUEDROITE
end if
Parametres(NbObjet) = Parametres(i)
Nom(NbObjet) = unNom
NbObjet = NbObjet + 1
End Sub
Sub AjouteSymetrique(unNom as String, listeObjets as String, options as String)
Dim p1() as String
Dim p2() as String
Dim lesObjets() as String
Dim i as Integer
Dim x1 as Double, y1 as Double
Dim x2 as Double, y2 as Double
Dim ang as Double
ChargeParametre(listeObjets, lesObjets, ",")
i = ChercheObjet(lesObjets(1))
ChargeParametre(Parametres(i), p2, ";")
ChargeParametre(Parametres(ChercheObjet(lesObjets(0))), p1, ";")
x1 = val(p1(0))
y1 = val(p1(1))
If Sorte(i) = TEP_POINT then
x2 = 2 * val(p2(0)) - x1
y2 = 2 * val(p2(1)) - y1
else
ang = CalculeAngle(val(p2(0)), val(p2(1)), val(p2(2)), val(p2(3))) + Pi / 2
TrouveIntersection(val(p2(0)), val(p2(1)), val(p2(2)), val(p2(3)), x1, y1, x1 + 10000 * cos(ang), y1 + 10000 * sin(ang), x2, y2)
x2 = 2 * x2 - x1
y2 = 2 * y2 - y1
End if
AjoutePoint(unNom, trim(str(x2)) & "," & trim(str(y2)), options)
End Sub
Sub AjouteTexte(unNom as String, listeObjets as String, options as String, leVraiTexte as String)
Dim lesObjets() as String
Dim i as Integer
Dim j as Integer
Dim unTexte as String
Dim x0 as string
Dim y0 as string
Dim p1() as String
Dim unTrait as Object
Dim uneTaille as integer
dim MiseEnForme(1, 1) as integer
Dim k as Integer
k = Len(leVraiTexte)
ReDim MiseEnForme(0 to k, 0 to 1) as Integer
ChargeParametre(listeObjets, lesObjets, ",")
i = ChercheObjet(lesObjets(0))
if i <> - 1 then
if Sorte(i) = TEP_POINT then
ChargeParametre(Parametres(i), p1, ";")
x0 = p1(0)
y0 = p1(1)
unTexte = lesObjets(1)
end if
else
x0 = lesObjets(0)
y0 = lesObjets(1)
unTexte = lesObjets(2)
end if
unTexte = mid(unTexte, 2, len(unTexte) - 2)
while instr(1, unTexte, "$")
i = instr(1, unTexte, "$")
j = instr(i + 1, unTexte, "$")
RemplaceTexte(unTexte, mid(unTexte, i, j - i + 1), RetourneVariable(mid(unTexte, i + 1, j - i - 1), options)
wend
if RetourneOption(options, "visibilite") = "v" then
ChargeParametre(RetourneOption(options, "position"), p1, ";")
x0 = trim(str(val(x0) + val(p1(0))))
y0 = trim(str(val(y0) - val(p1(1))))
if TesteTexte(leVraiTexte) then
leVraiTexte = TraduitTexte(leVraiTexte)
if instr(1, options, "rouge") <> 0 Then leVraiTexte = "color red {" & leVraiTexte & "}"
if instr(1, options, "magenta") <> 0 Then leVraiTexte = "color magenta {" & leVraiTexte & "}"
if instr(1, options, "blanc") <> 0 Then leVraiTexte = "color white {" & leVraiTexte & "}"
if instr(1, options, "noir") <> 0 Then leVraiTexte = "color black {" & leVraiTexte & "}"
if instr(1, options, "cyan") <> 0 Then leVraiTexte = "color cyan {" & leVraiTexte & "}"
if instr(1, options, "vert") <> 0 Then leVraiTexte = "color green {" & leVraiTexte & "}"
if instr(1, options, "bleu") <> 0 Then leVraiTexte = "color blue {" & leVraiTexte & "}"
if instr(1, options, "jaune") <> 0 Then leVraiTexte = "color yellow {" & leVraiTexte & "}"
if instr(1, options, "gras") <> 0 Then leVraiTexte = "bold {" & leVraiTexte & "}" Else leVraiTexte = "nbold {" & leVraiTexte & "}"
if instr(1, options, "italique") <> 0 Then leVraiTexte = "ital {" & leVraiTexte & "}" Else leVraiTexte = "nitalic {" & leVraiTexte & "}"
uneTaille = 14 + val(RetourneOption(options, "taille"))
leVraiTexte = "size " & trim(str(uneTaille)) & "{" & leVraiTexte & "}"
unTrait = InsereTexteBis(leVraiTexte, CalcAbscisse(val(x0)), CalcOrdonnee(val(y0)), 0, 1, 1)
else
RemplaceTexte(leVraiTexte, "£alpha£", Chr(&h03B1))
RemplaceTexte(leVraiTexte, "£beta£", Chr(&h03B2))
RemplaceTexte(leVraiTexte, "£chi£", Chr(&h03C7))
RemplaceTexte(leVraiTexte, "£delta£", Chr(&h03B4))
RemplaceTexte(leVraiTexte, "£epsilon£", Chr(&h03B5))
RemplaceTexte(leVraiTexte, "£phi£", Chr(&h03D5))
RemplaceTexte(leVraiTexte, "£gamma£", Chr(&h03B3))
RemplaceTexte(leVraiTexte, "£iota£", Chr(&h03B9))
RemplaceTexte(leVraiTexte, "£phi2£", Chr(&h03C6))
RemplaceTexte(leVraiTexte, "£kappa£", Chr(&h03BA))
RemplaceTexte(leVraiTexte, "£lambda£", Chr(&h03BB))
RemplaceTexte(leVraiTexte, "£mu£", Chr(&h03BC))
RemplaceTexte(leVraiTexte, "£nu£", Chr(&h03BD))
RemplaceTexte(leVraiTexte, "£omicron£", Chr(&h03BF))
RemplaceTexte(leVraiTexte, "£pi£", Chr(&h03C0))
RemplaceTexte(leVraiTexte, "£theta£", Chr(&h03B8))
RemplaceTexte(leVraiTexte, "£rho£", Chr(&h03C1))
RemplaceTexte(leVraiTexte, "£sigma£", Chr(&h03C3))
RemplaceTexte(leVraiTexte, "£tau£", Chr(&h03C4))
RemplaceTexte(leVraiTexte, "£upsilon£", Chr(&h03C5))
RemplaceTexte(leVraiTexte, "£sampi£", Chr(&h03D6))
RemplaceTexte(leVraiTexte, "£omega£", Chr(&h03C9))
RemplaceTexte(leVraiTexte, "£xi£", Chr(&h03BE))
RemplaceTexte(leVraiTexte, "£psi£", Chr(&h03C8))
RemplaceTexte(leVraiTexte, "£dzeta£", Chr(&h03B6))
RemplaceTexte(leVraiTexte, "£Alpha£", Chr(&h0391))
RemplaceTexte(leVraiTexte, "£Beta£", Chr(&h0392))
RemplaceTexte(leVraiTexte, "£Chi£", Chr(&h03A7))
RemplaceTexte(leVraiTexte, "£Delta£", Chr(&h0394))
RemplaceTexte(leVraiTexte, "£Epsilon£", Chr(&h0395))
RemplaceTexte(leVraiTexte, "£Phi£", Chr(&h03A6))
RemplaceTexte(leVraiTexte, "£Gamma£", Chr(&h0393))
RemplaceTexte(leVraiTexte, "£Eta£", Chr(&h0397))
RemplaceTexte(leVraiTexte, "£Iota£", Chr(&h0399))
RemplaceTexte(leVraiTexte, "£Phi2£", Chr(&h03D1))
RemplaceTexte(leVraiTexte, "Kappa£", Chr(&h039A))
RemplaceTexte(leVraiTexte, "£Lambda£", Chr(&h039B))
RemplaceTexte(leVraiTexte, "£Mu£", Chr(&h039C))
RemplaceTexte(leVraiTexte, "£Nu£", Chr(&h039D))
RemplaceTexte(leVraiTexte, "£Omicron£", Chr(&h039F))
RemplaceTexte(leVraiTexte, "£Pi£", Chr(&h03B2))
RemplaceTexte(leVraiTexte, "£Theta£", Chr(&h03A0))
RemplaceTexte(leVraiTexte, "£Rho£", Chr(&h0398))
RemplaceTexte(leVraiTexte, "£Sigma£", Chr(&h03A3))
RemplaceTexte(leVraiTexte, "£Tau£", Chr(&h03A4))
RemplaceTexte(leVraiTexte, "£Upsilon£", Chr(&h03A5))
RemplaceTexte(leVraiTexte, "£Sampi£", Chr(&h03C2))
RemplaceTexte(leVraiTexte, "£Omega£", Chr(&h03A9))
RemplaceTexte(leVraiTexte, "£Xi£", Chr(&h039E))
RemplaceTexte(leVraiTexte, "£Psi£", Chr(&h20D7))
RemplaceTexte(leVraiTexte, "£Dzeta£", Chr(&h0396))
uneTaille = 14 + val(RetourneOption(options, "taille"))
unTrait = InsereTexte(leVraiTexte, CalcAbscisse(val(x0)), CalcOrdonnee(val(y0)), uneTaille)
CouleurTexte(unTrait, RetourneOption(options, "couleur"))
End If
End If
Sorte(NbObjet) = TEP_TEXTE
Nom(NbObjet) = unNom
Parametres(NbObjet) = x0 & ";" & y0 & ";" & unTexte
NbObjet = NbObjet + 1
End Sub
Sub AdapteTexte(leTexte, liste)
Dim a as Integer
if instr(1, ucase(leTexte), ucase(liste) & " ") = 1 Then
leTexte = "%" & left(leTexte, len(liste)) & mid(leTexte, len(liste) + 1)
End if
do
a = instr(1, ucase(leTexte), " " & ucase(liste) & " ")
If a <> 0 Then
leTexte = left(leTexte, a - 1) & "%" & mid(leTexte, a, len(liste)) & mid(leTexte, a + len(liste))
End If
Loop While (a <> 0)
End Sub
Function TraduitTexte(leVraiTexte) as String
Dim unTexte as String
Dim i as integer, j as integer
Dim uneFraction as String
Dim num as String, den as String
unTexte = leVraiTexte
RemplaceTexte(unTexte, "£alpha£", "%alpha")
RemplaceTexte(unTexte, "£beta£", "%bêta")
RemplaceTexte(unTexte, "£gamma£", "%gamma")
RemplaceTexte(unTexte, "£delta£", "%delta")
RemplaceTexte(unTexte, "£epsilon£", "%epsilon")
RemplaceTexte(unTexte, "£dzeta£", "%zêta")
RemplaceTexte(unTexte, "£eta£", "%êta")
RemplaceTexte(unTexte, "£theta£", "%thêta")
RemplaceTexte(unTexte, "£iota£", "%iota")
RemplaceTexte(unTexte, "£kappa£", "%kappa")
RemplaceTexte(unTexte, "£lambda£", "%lambda")
RemplaceTexte(unTexte, "£mu£", "%mu")
RemplaceTexte(unTexte, "£nu£", "%nu")
RemplaceTexte(unTexte, "£xi£", "%xi")
RemplaceTexte(unTexte, "£omicron£", "%omicron")
RemplaceTexte(unTexte, "£pi£", "%pi")
RemplaceTexte(unTexte, "£rho£", "%rhô")
RemplaceTexte(unTexte, "£sigma£", "%sigma")
RemplaceTexte(unTexte, "£tau£", "%tau")
RemplaceTexte(unTexte, "£upsilon£", "%upsilon")
RemplaceTexte(unTexte, "£phi£", "%phi")
RemplaceTexte(unTexte, "£phi2£", "%varphi")
RemplaceTexte(unTexte, "£chi£", "%khi")
RemplaceTexte(unTexte, "£psi£", "%psi")
RemplaceTexte(unTexte, "£omega£", "%oméga")
RemplaceTexte(unTexte, "£Alpha£", "%ALPHA")
RemplaceTexte(unTexte, "£Beta£", "%BÊTA")
RemplaceTexte(unTexte, "£Gamma£", "%GAMMA")
RemplaceTexte(unTexte, "£Delta£", "%DELTA")
RemplaceTexte(unTexte, "£Epsilon£", "%EPSILON")
RemplaceTexte(unTexte, "£Dzeta£", "%ZÊTA")
RemplaceTexte(unTexte, "£Eta£", "%ÊTA")
RemplaceTexte(unTexte, "£Theta£", "%THÉTA")
RemplaceTexte(unTexte, "£Iota£", "%IOTA")
RemplaceTexte(unTexte, "£Kappa£", "%KAPPA")
RemplaceTexte(unTexte, "£Lambda£", "%LAMBDA")
RemplaceTexte(unTexte, "£Mu£", "%MU")
RemplaceTexte(unTexte, "£Nu£", "%NU")
RemplaceTexte(unTexte, "£Xi£", "%XI")
RemplaceTexte(unTexte, "£Omicron£", "%OMICRON")
RemplaceTexte(unTexte, "£Pi£", "%PI")
RemplaceTexte(unTexte, "£Rho£", "%RHÔ")
RemplaceTexte(unTexte, "£Sigma£", "%SIGMA")
RemplaceTexte(unTexte, "£Tau£", "%TAU")
RemplaceTexte(unTexte, "£Upsilon£", "%UPSILON")
RemplaceTexte(unTexte, "£Phi£", "%PHI")
RemplaceTexte(unTexte, "£Chi£", "%KHI")
RemplaceTexte(unTexte, "£Psi£", "%PSI")
RemplaceTexte(unTexte, "£Omega£", "%OMÉGA")
AdapteTexte(unTexte, "le")
do
i = instr(1, unTexte, "£r(")
if i <> 0 then
j = TrouveParenthese(unTexte, i + 3)
uneFraction = mid(unTexte, i + 3, j - i - 3)
unTexte = left(unTexte, i - 1) & "nroot{}{" & uneFraction & "}" & mid(unTexte, j + 1)
End If
loop while (i <> 0)
do
i = instr(1, unTexte, "£v(")
if i <> 0 then
j = TrouveParenthese(unTexte, i + 3)
uneFraction = mid(unTexte, i + 3, j - i - 3)
unTexte = left(unTexte, i - 1) & "widevec{" & uneFraction & "}" & mid(unTexte, j + 1)
End If
loop while (i <> 0)
do
i = instr(1, unTexte, "£a(")
if i <> 0 then
j = TrouveParenthese(unTexte, i + 3)
uneFraction = mid(unTexte, i + 3, j - i - 3)
unTexte = left(unTexte, i - 1) & "widehat{" & uneFraction & "}" & mid(unTexte, j + 1)
End If
loop while (i <> 0)
do
i = instr(1, unTexte, "£f(")
if i <> 0 then
j = TrouveParenthese(unTexte, i + 3)
uneFraction = mid(unTexte, i + 3, j - i - 3)
RetourneNumDen(uneFraction, num, den)
unTexte = left(unTexte, i - 1) & "{" & num & "} over {" & den & "}" & mid(unTexte, j + 1)
End If
loop while (i <> 0)
do
i = instr(1, unTexte, "£i(")
if i <> 0 then
j = TrouveParenthese(unTexte, i + 3)
uneFraction = mid(unTexte, i + 3, j - i - 3)
unTexte = left(unTexte, i - 1) & "_{" & uneFraction & "}" & mid(unTexte, j + 1)
End If
loop while (i <> 0)
do
i = instr(1, unTexte, "£e(")
if i <> 0 then
j = TrouveParenthese(unTexte, i + 3)
uneFraction = mid(unTexte, i + 3, j - i - 3)
unTexte = left(unTexte, i - 1) & "^{" & uneFraction & "}" & mid(unTexte, j + 1)
End If
loop while (i <> 0)
do
i = instr(1, unTexte, "£c(")
if i <> 0 then
j= TrouveParenthese(unTexte, i + 3)
uneFraction = mid(unTexte, i + 3, j - i - 3)
unTexte = left(unTexte, i - 1) & "[" & uneFraction & "]" & mid(unTexte, j + 1)
End if
loop while (i <> 0)
do
i = instr(1, unTexte, "£p(")
if i <> 0 then
j= TrouveParenthese(unTexte, i + 3)
uneFraction = mid(unTexte, i + 3, j - i - 3)
unTexte = left(unTexte, i - 1) & "(" & uneFraction & ")" & mid(unTexte, j + 1)
End if
Loop While (i <> 0)
TraduitTexte() = unTexte
End Function
Sub RetourneNumDen(uneFraction, num, den)
Dim np
Dim i
np = 0
For i = 1 To len(uneFraction)
if mid(uneFraction, i, 1) = "(" then np = np + 1
if mid(uneFraction, i, 1) = ")" Then np = np - 1
if mid(uneFraction, i, 1) = "," And np = 0 then
num = left(uneFraction, i - 1)
den = mid(uneFraction, i + 1)
Exit Sub
End if
Next i
End Sub
Function TrouveParenthese(unTexte, n) as Integer
Dim np
Dim i
np = 0
for i = n to len(unTexte)
if mid(unTexte, i, 1) = ")" then
if np = 0 then
TrouveParenthese() = i
Exit Function
else
np = np - 1
end if
End If
If mid(unTexte, i, 1) = "(" Then np = np + 1
next i
End Function
Function TesteTexte(leTexte) as Boolean
TesteTexte() = False
if instr(1, leTexte, "£") then TesteTexte() = True
if instr(1, leTexte, "£a(")<>0 then TesteTexte() = True
if instr(1, leTexte, "£c(")<>0 then TesteTexte() = True
if instr(1, leTexte, "£e(")<>0 then TesteTexte() = True
if instr(1, leTexte, "£f(")<>0 then TesteTexte() = True
if instr(1, leTexte, "£i(")<>0 then TesteTexte() = True
if instr(1, leTexte, "£p(")<>0 then TesteTexte() = True
if instr(1, leTexte, "£r(")<>0 then TesteTexte() = True
if instr(1, leTexte, "£v(")<>0 then TesteTexte() = True
if instr(1, leTexte, "£i(")<>0 then TesteTexte() = True
End Function
Sub AjouteTexteOld(unNom as String, listeObjets as String, options as String, leVraiTexte as String)
Dim lesObjets() as String
Dim i as Integer
Dim j as Integer
Dim unTexte as String
Dim x0 as string
Dim y0 as string
Dim p1() as String
Dim unTrait as Object
ChargeParametre(listeObjets, lesObjets, ",")
i = ChercheObjet(lesObjets(0))
if i <> - 1 then
if Sorte(i) = TEP_POINT then
ChargeParametre(Parametres(i), p1, ";")
x0 = p1(0)
y0 = p1(1)
unTexte = lesObjets(1)
end if
else
x0 = lesObjets(0)
y0 = lesObjets(1)
unTexte = lesObjets(2)
end if
unTexte = mid(unTexte, 2, len(unTexte) - 2)
while instr(1, unTexte, "$")
i = instr(1, unTexte, "$")
j = instr(i + 1, unTexte, "$")
RemplaceTexte(unTexte, mid(unTexte, i, j - i + 1), RetourneVariable(mid(unTexte, i + 1, j - i - 1), options))
wend
if RetourneOption(options, "visibilite") = "v" then
ChargeParametre(RetourneOption(options, "position"), p1, ";")
x0 = trim(str(val(x0) + val(p1(0))))
y0 = trim(str(val(y0) - val(p1(1))))
' unTrait = InsereTexte(unTexte, CalcAbscisse(val(x0)), CalcOrdonnee(val(y0)))
unTrait = InsereTexte(leVraiTexte, CalcAbscisse(val(x0)), CalcOrdonnee(val(y0)))
CouleurTexte(unTrait, RetourneOption(options, "couleur"))
End If
Sorte(NbObjet) = TEP_TEXTE
Nom(NbObjet) = unNom
Parametres(NbObjet) = x0 & ";" & y0 & ";" & unTexte
NbObjet = NbObjet + 1
End Sub
Sub AjouteTranslation(unNom as string, listeObjets as string)
Dim lesObjets() as String
ChargeParametre(listeObjets, lesObjets, ",")
if Sorte(ChercheObjet(lesObjets(0))) = TEP_VECTEUR then
Parametres(NbObjet) = Parametres(ChercheObjet(lesObjets(0)))
else
Parametres(NbObjet) = Parametres(ChercheObjet(lesObjets(0))) & ";" & Parametres(ChercheObjet(lesObjets(1)))
End if
Nom(NbObjet) = unNom
Sorte(NbObjet) = TEP_TRANSLATION
NbObjet = NbObjet + 1
End Sub
Sub AjouteVariable(unNom As String, listeObjets as String, options as String)
Parametres(NbObjet) = options
Nom(NbObjet) = unNom
Sorte(NbObjet) = TEP_VARIABLE
NbObjet = NbObjet + 1
End Sub
Sub AjouteReel(unNom As String, listeObjets as String, listeCoords as String, options as String)
' Aurélien Parametres(NbObjet) = options & ";" & left(listeCoords, len(listeCoords) - 1)
Parametres(NbObjet) = options & ";" & listeCoords
Nom(NbObjet) = unNom
Sorte(NbObjet) = TEP_REEL
NbObjet = NbObjet + 1
End Sub
Sub AjouteVecteur(unNom as String, unObjet as string)
Nom(NbObjet) = unNom
Sorte(NbObjet) = TEP_VECTEUR
Parametres(NbObjet) = "0;0;" & unObjet
NbObjet = NbObjet + 1
End Sub
function CalcAbscisse(x0 as single) as double
rem CalcAbscisse = xorig + val(x0)*xunit
dim xx as single
xx = x0 - xmin
xx = xx * xunit
CalcAbscisse = xx
end function
function CalcOrdonnee(y0 as single) as double
rem CalcOrdonnee = yorig - val(y0)*yunit
dim yy as single
yy = max(ymin, ymax) - y0
yy = yy * yunit
CalcOrdonnee = yy
end function
function ChercheObjet(unNom as string) as integer
Dim i
ChercheObjet = - 1
for i = 0 to NbObjet - 1
if Trim(Nom(i)) = Trim(unNom) then
ChercheObjet = i
exit for
end if
next i
end function
Function Evalue(unTexte As String) as Double
Dim a as Integer
a = instr(1, unTexte, "/")
if a <> 0 then
Evalue = val(Left(unTexte, a - 1)) / val(mid(unTexte, a + 1))
else
Evalue = val(unTexte)
End If
End Function
Sub ExtraitBoiteTEP(leTexte as String)
Dim i as integer
Dim lesLignes() as String
ChargeParametre(leTexte, lesLignes, chr(10))
If ubound(lesLignes()) = 0 Then
ChargeParametre(leTexte, lesLignes, chr(13))
End If
redim ligne(lbound(lesLignes) to ubound(lesLignes)) As String
redim options(lbound(lesLignes) to ubound(lesLignes)) As String
redim coords(lbound(lesLignes) to ubound(lesLignes)) As String
for i = lbound(lesLignes) to ubound(lesLignes)
ConversionLigneTexte(lesLignes(i), options(i), ligne(i), coords(i))
oTepForm.GetControl("ProgressBar1").Value = 100 * i / UBound(lesLignes())
next i
End Sub
Sub ExtraitLigneTep(ligne() as string, options() as string)
dim f1 as integer
dim i as integer
dim uneLigne as string
dim uneAction as Boolean
Dim ti as Integer
' on error goto fin
f1 = freefile
i = 0
DescriptionOOoTep = ""
Open NomFichier For Input as #f1
do while not eof(f1)
line input #f1, uneLigne
i = i + 1
loop
close #f1
redim ligne(0 to i - 1) As String
redim options(0 to i - 1) As String
redim coords(0 to i - 1) As String
oTepForm.GetControl("ProgressBar1").Value = 50
ti = i
f1 = freefile
i = 0
uneAction = False
Open NomFichier For Input as #f1
do while not eof(f1)
line input #f1, uneLigne
DescriptionOOoTep = DescriptionOOoTep & uneLigne & chr(10) & chr(13)
ConversionLigneTexte(uneLigne, options(i), ligne(i), coords(i))
i = i + 1
oTepForm.GetControl("ProgressBar1").Value = 50 + 50 * i / ti
loop
close #f1
Exit Sub
fin:
MsgBox1 "Je n'ai pas trouvé le fichier script indiqué !"
end Sub
Function NombreTexte(unTexte as String, leTexte as String) as Integer
Dim i as Integer
Dim no as Integer
no = 0
i = instr(1, unTexte, leTexte)
while(i <> 0)
no = no + 1
i = instr(i + 1, unTexte, leTexte)
wend
NombreTexte() = no
End Function
Sub ConversionLigneTexte(uneLigne as String, lesOptions as String, laLigne as String, lesCoords as string)
Dim j as integer
Dim i as integer
dim k as integer
dim lesTextes() as String
Dim nTexte as Integer
Dim debug as String
' RemplaceTexte uneLigne, chr(160), ""
nTexte = NombreTexte(uneLigne, """") / 2
if nTexte > 0 then Redim lesTextes(nTexte - 1) as String
k = 0
for i = 0 to nTexte - 1
j = instr(k + 1, uneLigne, """")
k = instr(j + 1, uneLigne, """")
lesTextes(i) = mid(uneLigne, j, k - j + 1)
next i
for i = 0 to nTexte - 1
RemplaceTexte uneligne, lesTextes(i), "OOoTepTexte" & trim(str(i))
next i
lesOptions = ""
j = instr(1, uneLigne, "{")
if j <> 0 then
k = instr(j, uneLigne, "}")
lesOptions = mid(uneLigne, j, k - j + 1)
laLigne = left(uneLigne, j - 1) & mid(uneLigne, k + 1)
else
laLigne = uneLigne
end if
j = instr(1, laLigne, "&&")
if j <> 0 then
k = instr(j, laLigne, ";")
lesCoords = trim(mid(laLigne, j + 2, k - j - 3))
if right(lesCoords, 1) = "&" then lesCoords = left(lesCoords, len(lesCoords) - 1)
RemplaceTexte(lesCoords, "&", ",")
laLigne = left(laLigne, j - 1) & mid(laLigne, k + 1)
end if
for j = 1 to len(lesOptions)
Select Case mid(lesOptions, j, 1)
case "}", "{"
lesOptions = left(lesOptions, j - 1) & mid(lesOptions, j + 1)
case ",", " "
lesOptions = left(lesOptions, j - 1) & ";" & mid(lesOptions, j + 1)
case "("
do while(mid(lesOptions, j, 1) <> ")")
j = j + 1
loop
case """"
j = j + 1
do while(mid(lesOptions, j, 1) <> """")
j = j + 1
loop
End Select
next j
for j = 1 to len(laLigne)
Select Case mid(laLigne, j, 1)
case "}", "{"
laLigne = left(laLigne, j - 1) & mid(laLigne, j + 1)
case ",", " ", "="
laLigne = left(laLigne, j - 1) & ";" & mid(laLigne, j + 1)
case "("
dim np
np = 0
j = j + 1
do while(mid(laLigne, j, 1) <> ")") or np > 0
if mid(laLigne, j, 1) = "(" then np = np + 1
if mid(laLigne, j, 1) = ")" then np = np - 1
j = j + 1
loop
case """"
j = j + 1
do while(mid(laLigne, j, 1) <> """")
j = j + 1
loop
End Select
next j
RemplaceTexte(laLigne, "(", ";")
RemplaceTexte(laLigne, ")", ";")
RemplaceTexte laLigne, ";;", ";"
RemplaceTexte laLigne, ";;", ";"
if left(laLigne, 1) = ";" then laLigne = mid(laLigne, 2)
if left(lesOptions, 1) = ";" then lesOptions = mid(lesOptions, 2)
if right(laLigne, 1) = ";" then laLigne = left(laLigne, len(laLigne) - 1)
if right(lesOptions, 1) = ";" then lesOptions = left(lesOptions, len(lesOptions) - 1)
for i = nTexte - 1 to 0 step - 1
RemplaceTexte laLigne, "OOoTepTexte" & trim(str(i)), lesTextes(i)
next i
End Sub
Sub ImageDroite(i as Integer, p1 as String, p2 as String)
Dim d1 As String
Dim d2 As String
Dim p3() As String
ChargeParametre(p1, p3, ";")
ImagePoint(i, p3(0) & ";" & p3(1), d1)
ImagePoint(i, p3(2) & ";" & p3(3), d2)
p2 = d1 & "," & d2
End Sub
Function ImageRayon(i as Integer, unRayon as Double) as Double
Dim p3() as String
Dim k as Double
ChargeParametre(Parametres(i), p3, ";")
Select Case Sorte(i)
case TEP_SIMILITUDE
k = val(p3(2))
case TEP_HOMOTHETIE
k = val(p3(2))
case TEP_ROTATION, TEP_TRANSLATION, TEP_SYMETRIQUEPOINT, TEP_SYMETRIQUEDROITE
k = 1
End Select
ImageRayon = unRayon * k
End Function
Function ImageAngle(i as Integer, unangle as double) as double
Dim p3() as String
Dim ang as Double
ChargeParametre(Parametres(i), p3, ";")
Select Case Sorte(i)
case TEP_SIMILITUDE
ang = val(p3(3)) * Miif(angle_en_radian, Pi / 180, 1)
ImageAngle = unangle + ang
case TEP_HOMOTHETIE
ImageAngle = unangle
case TEP_ROTATION
ang = val(p3(2)) * Miif(angle_en_radian, Pi / 180, 1)
ImageAngle = unangle + ang
case TEP_TRANSLATION
ImageAngle = unangle
case TEP_SYMETRIQUEPOINT
ang = Miif(angle_en_radian, Pi, 180)
ImageAngle = unangle + ang
case TEP_SYMETRIQUEDROITE
ang = CalculeAngle(val(p3(0)), val(p3(1)), val(p3(2)), val(p3(3))) + Pi / 2
ImageAngle = unangle + ang
End Select
End Function
Sub ImagePoint(i as Integer, p1 as String, p2 as String)
Dim p3() as String
Dim ang as Double
Dim unRayon as Double
Dim k as Double
Dim x0 as Double
Dim y0 as Double
Dim x1 as Double
Dim y1 as Double
Dim x2 as Double
Dim y2 as Double
ChargeParametre(p1, p3, ";")
x1 = val(p3(0))
y1 = val(p3(1))
ChargeParametre(Parametres(i), p3, ";")
Select Case Sorte(i)
case TEP_SIMILITUDE
x0 = val(p3(0))
y0 = val(p3(1))
k = val(p3(2))
ang = val(p3(3)) * Miif(angle_en_radian, 1, Pi / 180)
ang = CalculeAngle(x0, y0, x1, y1) + ang
unRayon = sqr((x0 - x1) ^ 2 + (y0 - y1) ^ 2)
x2 = x0 + unRayon * cos(ang)
y2 = y0 + unRayon * sin(ang)
x2 = k * (x2 - x0) + x0
y2 = k * (y2 - y0) + y0
case TEP_HOMOTHETIE
x0 = val(p3(0))
y0 = val(p3(1))
k = val(p3(2))
x2 = k * (x1 - x0) + x0
y2 = k * (y1 - y0) + y0
case TEP_ROTATION
x0 = val(p3(0))
y0 = val(p3(1))
ang = val(p3(2)) * Miif(angle_en_radian, 1, Pi / 180)
ang = CalculeAngle(x0, y0, x1, y1) + ang
unRayon = sqr((x0 - x1) ^ 2 + (y0 - y1) ^ 2)
x2 = x0 + unRayon * cos(ang)
y2 = y0 + unRayon * sin(ang)
case TEP_TRANSLATION
x2 = x1 + val(p3(2)) - val(p3(0))
y2 = y1 + val(p3(3)) - val(p3(1))
case TEP_SYMETRIQUEPOINT
x2 = 2 * val(p3(0)) - x1
y2 = 2 * val(p3(1)) - y1
case TEP_SYMETRIQUEDROITE
ang = CalculeAngle(val(p3(0)), val(p3(1)), val(p3(2)), val(p3(3))) + Pi / 2
TrouveIntersection(val(p3(0)), val(p3(1)), val(p3(2)), val(p3(3)), x1, y1, x1 + 1000 * cos(ang), y1 + 1000 * sin(ang), x2, y2)
x2 = 2 * x2 - x1
y2 = 2 * y2 - y1
End Select
p2 = trim(str(x2)) & "," & trim(str(y2))
End Sub
function InsereArcDeCercle(xorig as long, yorig as long, depart as long, arrivee as long, Rayon as long, Optional formeFerme as Boolean) as object
Dim UneForme As object
Dim aPoint As New com.sun.star.awt.Point
Dim aSize As New com.sun.star.awt.Size
If IsMissing(formeFerme) then formeFerme = False
aPoint.x = xorig - Rayon
aPoint.y = yorig - Rayon
aSize.Width = Rayon * 2
asize.Height = Rayon * 2
UneForme = oDocumentDessin.createInstance("com.sun.star.drawing.EllipseShape")
' UneForme.AnchorType = com.sun.star.text.TextContentAnchorType.AT_PAGE
UneForme.Position = aPoint
UneForme.Size = aSize
oDocumentDessin.DrawPages.GetByIndex(0).add(UneForme)
if formeFerme then
UneForme.CircleKind = com.sun.star.drawing.CircleKind.SECTION
else
UneForme.CircleKind = com.sun.star.drawing.CircleKind.ARC
end if
UneForme.CircleStartAngle = depart
if arrivee>36000 then arrivee = arrivee - 36000
UneForme.CircleEndAngle = arrivee
oGroupeDessin.Add(UneForme)
InsereArcDeCercle() = UneForme
End function
function InsereCercle(xorig as long, yorig as long, Rayon as long) as object
Dim UneForme As object
Dim aPoint As New com.sun.star.awt.Point
Dim aSize As New com.sun.star.awt.Size
aPoint.x = xorig - Rayon
aPoint.y = yorig - Rayon
aSize.Width = Rayon * 2
asize.Height = Rayon * 2
UneForme = oDocumentDessin.createInstance("com.sun.star.drawing.EllipseShape")
' UneForme.AnchorType = com.sun.star.text.TextContentAnchorType.AT_PAGE
UneForme.Position = aPoint
UneForme.Size = aSize
oDocumentDessin.DrawPages.GetByIndex(0).add(UneForme)
UneForme.CircleStartAngle = 0
UneForme.CircleEndAngle = 3600
UneForme.CircleKind = com.sun.star.drawing.CircleKind.FULL
oGroupeDessin.Add(UneForme)
InsereCercle() = UneForme
End function
function InsereLigne(x0 as long, y0 as long, x1 as long, y1 as long, Optional unGroupe as Object) as object
Dim aPosition as new com.sun.star.awt.Point
Dim TheSize as new com.sun.star.awt.Size
Dim xShape as object
xShape = oDocumentDessin.createInstance("com.sun.star.drawing.LineShape")
' xShape.AnchorType = com.sun.star.text.TextContentAnchorType.AT_PAGE
xShape.LineWidth = 20
aPosition.X = x0
aPosition.Y = y0
xShape.Position = aPosition
TheSize.width = x1 - x0
TheSize.height = y1 - y0
xShape.Size = TheSize
' ThisComponent.DrawPage.add( xShape )
oDocumentDessin.DrawPages.GetByIndex(0).add( xShape )
if IsMissing(unGroupe) then
oGroupeDessin.add(xShape)
else
unGroupe.add(xShape)
end if
InsereLigne() = xShape
End Function
Function InsereCourbe(secArray() as single, n as integer) As object
dim oShape as Object
dim i as integer
dim oCoord as New com.sun.star.awt.Point
dim xl as single, yl as single
Redim oCoord(0 to n - 1) as New com.sun.star.awt.Point
oShape = oDocumentDessin.createInstance( "com.sun.star.drawing.PolyLineShape")
for i = 0 to n - 1
xl = secArray(i, 0)
yl = secArray(i, 1)
oCoord(i).x = xl
oCoord(i).y = yl
next i
oDocumentDessin.DrawPages.GetByIndex(0).add(oShape)
oShape.PolyPolygon = Array(oCoord())
oGroupeDessin.Add(oShape)
InsereCourbe = oShape
End Function
Function InserePolygoneB(secArray() as single, n as integer) As object
dim oShape as Object
dim i as integer
dim groupage as object
dim oCoord as New com.sun.star.awt.Point
Redim oCoord(0 to n - 1) as New com.sun.star.awt.Point
oShape = oDocumentDessin.createInstance( "com.sun.star.drawing.PolyPolygonShape")
for i = 0 to n - 1
oCoord(i).x = secArray(i, 0)
oCoord(i).y = secArray(i, 1)
next i
oDocumentDessin.DrawPages.GetByIndex(0).add(oShape)
oShape.PolyPolygon = Array(oCoord())
oGroupeDessin.add(oShape)
InserePolygoneB = oShape
End Function
Sub EnleveEsperluette(unTexte as String)
Dim param() as String
ChargeParametre unTexte, param(), "&"
if lbound(param()) < ubound(param()) then
if right(param(0), 1) = ";" then param(0) = left(param(0), len(param(0)) - 1)
unTexte = param(lbound(param())) & param(ubound(param()))
End if
End Sub
Function RetrouveScriptTep(unTexte as String) as String
Dim a, i
Dim param() as String
Dim leTexte as String
leTexte = unTexte
a = instr(1, leTexte, "@oootep;")
if a <> 0 then leTexte = left(leTexte, a - 1)
ChargeParametre leTexte, param(), chr(10)
leTexte = ""
for i = lbound(param()) to ubound(param())
EnleveEsperluette(param(i))
leTexte = leTexte & param(i) & chr(10)
next i
RetrouveScriptTep() = leTexte
End Function
Function ChercheDescription2(unNom, unGroupe) as string
if unGroupe.Name="OOoTep" then
ChercheDescription2() = unGroupe.Description
else
ChercheDescription2() = ""
end if
End Function
Function ChercheDescription(unNom, unGroupe) as String
Dim uneForme as Object
Dim i, a
on error goto fin
a = unGroupe.ShapeType
if unGroupe.ShapeType = "com.sun.star.drawing.GroupShape" Then
for i = 0 to unGroupe.Count - 1
uneForme = unGroupe(i)
if uneForme.ShapeType = "com.sun.star.drawing.GroupShape" Then
ChercheDescription() = ChercheDescription(unNom, uneForme)
else
a = uneForme.Name
if uneForme.Name = "DescriptionOOoTep" then
ChercheDescription() = uneForme.Description
Exit Function
end if
End if
next i
else
if unGroupe.Name = "DescriptionOOoTep" then
ChercheDescription() = unGroupe.Description
Exit Function
end if
End if
fin:
on error goto 0
ChercheDescription() = ""
End Function
Sub MsgBox1(unMessage as String)
MsgBox unMessage, 0, "OOoTep - v " & VERSION_OOOTEP
End Sub
Function RetourneDescriptionTep() as String
Dim unCurseur as Object
Dim curseurVisible as Object
Dim uneDescription as String
Dim oDispatcher as Object
Dim Array()
' uneDescription = ChercheDescription("DescriptionOOoTep", thisComponent.CurrentSelection(0))
uneDescription = ChercheDescription2("DescriptionOOoTep", thisComponent.CurrentSelection(0))
if uneDescription = "" then
MsgBox1 "Il faut sélectionner une figure réalisée avec OOoTep !"
else
TextToClipBoard(uneDescription)
End if
RetourneDescriptionTep() = uneDescription
End Function
Function RetourneDescriptionTepBis() as String
Dim unCurseur as Object
Dim curseurVisible as Object
Dim uneDescription as String
Dim oDispatcher as Object
Dim Array()
uneDescription = ChercheDescription("DescriptionOOoTep", thisComponent.CurrentSelection(0))
if uneDescription = "" then
MsgBox1 "Il faut sélectionner une figure réalisée avec OOoTep !"
else
oDocumentTexte = StarDesktop.LoadComponentFromURL("private:factory/swriter", "_blank", 0, Array())
oDocumentTexte.lockControllers
curseurVisible = oDocumentTexte.currentController.viewcursor
CurseurVisible.String = uneDescription
oDispatcher = createUnoService( "com.sun.star.frame.DispatchHelper" )
oDispatcher.executeDispatch( oDocumentTexte.getCurrentController().Frame, ".uno:Cut", "", 0, Array() )
on error resume next
oDocumentTexte.unlockControllers
oDocumentTexte.close(true)
on error goto 0
End if
RetourneDescriptionTep() = uneDescription
End Function
Sub AjouteDescriptionTep2()
Dim unObjet as Object
set unObjet = oPageDessin(0)
unObjet.Description = DescriptionOOoTep
unObjet.Name="OOoTep"
End Sub
Sub AjouteDescriptionTep()
Dim aPoint As New com.sun.star.awt.Point
Dim aSize As New com.sun.star.awt.Size
Dim xShape as object
Dim oTexte as Object
dim ocursor as Object
Dim uneTaille as Integer
Dim unStyle as Integer
Dim uneCouleur as String
uneTaille = 1
unStyle = 0
unecouleur = RGB(255, 255, 255)
aPoint = oPageDessin(0).Position
xShape = oDocumentDessin.createInstance("com.sun.star.drawing.TextShape")
aSize.Width = 1
aSize.Height = 1
xShape.Position = aPoint
xShape.Size = aSize
xShape.zorder = - 1
xShape.Name = "DescriptionOOoTep"
oDocumentDessin.DrawPages.GetByIndex(0).add(xShape)
xShape.Text.TextAutoGrowWidth = False
xShape.Text.TextAutoGrowHeight = False
' xShape.String = DescriptionOOoTep
xShape.Description = DescriptionOOoTep
StylePolice(xShape, uneTaille, unStyle)
CouleurTexte(xShape, uneCouleur)
xShape.Size = aSize
oGroupeDessin.add(xShape)
End Sub
Function InsereTexte(UnTexte as string, x0 as long , y0 as long, Optional uneTaille as integer, Optional unStyle as integer, Optional UneCouleur as string, Optional AlignHoriz as integer, Optional AlignVert as integer) as object
Dim aPoint As New com.sun.star.awt.Point
Dim aSize As New com.sun.star.awt.Size
Dim xShape as object
Dim oTexte as Object
dim ocursor as Object
if ismissing(AlignHoriz) then AlignHoriz = AL_GAUCHE
if ismissing(AlignVert) then AlignVert = AL_HAUT
if ismissing(uneTaille) then uneTaille = OOoTep_taillepolice
if ismissing(unStyle) then unStyle = 0
if ismissing(uneCouleur) then unecouleur = OOoTep_couleurpolice
xShape = oDocumentDessin.createInstance("com.sun.star.drawing.TextShape")
aPoint.X = x0
aPoint.Y = y0
aSize.Width = 10
aSize.Height = 10
xShape.Position = aPoint
xShape.Size = aSize
oDocumentDessin.DrawPages.GetByIndex(0).add(xShape)
xShape.String = UnTexte
xShape.Text.CharFontName = OOoTep_nompolice
StylePolice(xShape, uneTaille, unStyle)
CouleurTexte(xShape, uneCouleur)
xShape.Text.TextAutoGrowWidth = True
xShape.Text.TextAutoGrowHeight = True
aSize = xShape.Size
aPoint = xShape.Position
if AlignHoriz = AL_GAUCHE then aPoint.x = aPoint.x + aSize.Width / 2
if AlignHoriz = AL_DROITE then aPoint.x = aPoint.x - aSize.Width / 2
if AlignVert = AL_CENTRE then aPoint.y = aPoint.y - aSize.Height / 2
if AlignVert = AL_BAS then aPoint.y = aPoint.y - aSize.Height
xShape.Position = aPoint
oGroupeDessin.add(xShape)
InsereTexte() = xShape
end Function
Function InsereVecteur(x0, y0, x1, y1, Optional uneCouleur as string) as Object
dim unTrait as Object
dim ang as double
dim unPolygone as Object
Dim secArray(0 to 2, 0 to 1) as single
if ismissing(uneCouleur) then uneCouleur = OOoTep_couleurdutrait
unTrait = InsereLigne(x0, y0, x1, y1)
unTrait.LineColor = uneCouleur
ang = CalculeAngle(x0, y0, x1, y1)
secArray(0, 0) = x1
secArray(0, 1) = y1
secArray(1, 0) = x1 + 200 * cos(ang + 5 * Pi / 6)
secArray(1, 1) = y1 + 200 * sin(ang + 5 * Pi / 6)
secArray(2, 0) = x1 + 200 * cos(ang - 5 * Pi / 6)
secArray(2, 1) = y1 + 200 * sin(ang - 5 * Pi / 6)
unPolygone = InserePolygoneB(secArray(), 3)
unPolygone.LineColor = uneCouleur
unPolygone.FillStyle = com.sun.star.drawing.FillStyle.SOLID
unPolygone.FillColor = uneCouleur
InsereVecteur = unPolygone
End Function
Function MarqueAngleDroit(xd, yd, xs, ys, options as String) as object
Dim secArray(0 to 3, 0 to 1) as single
Dim ang as Double
Dim uneLongueur as Double
ang = CalculeAngle(xd, yd, xs, ys) - (val(RetourneOption(options, "quadrant")) - 1) * Pi / 2
uneLongueur = min(sqr((xd - xs) ^ 2 + (yd - ys) ^ 2) / 5, 400)
secArray(0, 0) = xd + uneLongueur * Cos(ang)
secArray(0, 1) = yd + uneLongueur * Sin(ang)
secArray(1, 0) = xd + uneLongueur * (Cos(ang) - Sin(ang))
secArray(1, 1) = yd + uneLongueur * (Sin(ang) + Cos(ang))
secArray(2, 0) = xd - uneLongueur * Sin(ang)
secArray(2, 1) = yd + uneLongueur * Cos(ang)
secArray(3, 0) = xd
secArray(3, 1) = yd
if RetourneOption(options, "opacite") = "0" then
MarqueAngleDroit = InsereCourbe(secArray(), 3)
else
MarqueAngleDroit = InserePolygoneB(secArray(), 4)
end if
End function
Function RepereTraceEnPoche() as String
Dim FP as Object, LesFichiers() as string
FP = CreateUnoService("com.sun.star.ui.dialogs.FilePicker")
With FP
.DisplayDirectory = ConvertToURL("")
.appendFilter("Fichiers swf", "*.swf")
.appendFilter("Tous", "*.*")
.CurrentFilter = "Fichiers swf"
if .Execute = com.sun.star.ui.dialogs.ExecutableDialogResults.OK then
lesFichiers() = .Files
RepereTraceEnPoche() = lesFichiers(0)
else
RepereTraceEnPoche() = ""
end if
.Dispose
end With
End Function
function OuvreFichierTEP() as integer
Dim FP as Object, LesFichiers() as string
nomFichier = ""
FP = CreateUnoService("com.sun.star.ui.dialogs.FilePicker")
With FP
.DisplayDirectory = ConvertToURL("")
.appendFilter("Fichiers Tep", "*.txt")
.appendFilter("Tous", "*.*")
.CurrentFilter = "Fichiers Tep"
if .Execute = com.sun.star.ui.dialogs.ExecutableDialogResults.OK then
lesFichiers() = .Files
nomFichier = lesFichiers(0)
OuvreFichierTEP = 1
else
OuvreFichierTEP = 0
end if
.Dispose
end With
end function
function RetourneCouleur(uneCouleur as string) as long
Dim laCouleur as String
laCouleur = uneCouleur
select case uneCouleur
case "blanc"
laCouleur = "0xFFFFFF"
case "bleu"
laCouleur = "0x0000FF"
case "bleuciel"
laCouleur = "0xCEDDFF"
case "bleufonce"
laCouleur = "0x000066"
case "bleuocean"
laCouleur = "0x6666FF"
case "brique"
laCouleur = "0x996666"
case "cyan"
laCouleur = "0x00FFFF"
case "grisclair"
laCouleur = "0xCCCCCC"
case "grisfonce"
laCouleur = "0x666666"
case "jaune"
laCouleur = "0xFFFF00"
case "jauneclair"
laCouleur = "0xFFFF99"
case "jaunepaille"
laCouleur = "0xCCCC33"
case "kaki"
laCouleur = "0x666633"
case "kakiclair"
laCouleur = "0xC4C486"
case "magenta"
laCouleur = "0xff00ff"
case "marron"
laCouleur = "0x996633"
case "marronfonce"
laCouleur = "0x663333"
case "noir"
laCouleur = "0x000000"
case "orange"
laCouleur = "0xFF9900"
case "rose"
laCouleur = "0xFF9DFF"
case "rouge"
laCouleur = "0xFF0000"
case "rougeclair"
laCouleur = "0xFF5E5E"
case "rougefonce"
laCouleur = "0x990000"
case "sapin"
laCouleur = "0x004040"
case "saumon"
laCouleur = "0xFF9999"
case "vert"
laCouleur = "0x00B000"
case "vertclair"
laCouleur = "0x00FF00"
case "vertfonce"
laCouleur = "0x006600"
case "vertpale"
laCouleur = "0xBDD7CC"
case "violetfonce"
laCouleur = "0x5B005B"
case "violet"
laCouleur = "0x9966FF"
End Select
if left(laCouleur, 2) = "0x" then
RetourneCouleur = rgb(Clng("&H" & mid(laCouleur, 3, 2)), Clng("&H" & mid(laCouleur, 5, 2)), Clng("&H" & mid(laCouleur, 7, 2)))
else
if laCouleur = "" then
RetourneCouleur = OOoTep_couleurdutrait
else
RetourneCouleur = laCouleur
end if
end if
end function
function RetourneOption(liste as string, nom as string) as string
dim a as integer, b as integer, i
dim uTexte as String
select case nom
case "decimale"
RetourneOption = ""
for i = 0 to 10
if TrouveMot(liste, "dec" & trim(str(i))) then RetourneOption = trim(str(i))
next i
case "pointille"
RetourneOption = ""
if TrouveMot(liste, "p1") then RetourneOption = "p1"
if TrouveMot(liste, "p2") then RetourneOption = "p2"
case "coord"
RetourneOption = ""
if TrouveMot(liste, "coord") then RetourneOption = "coord"
if TrouveMot(liste, "coordx") then RetourneOption = "coordx"
if TrouveMot(liste, "coordy") then RetourneOption = "coordy"
case "taille"
RetourneOption = "0"
if TrouveMot(liste, "car-4") then RetourneOption = "-6"
if TrouveMot(liste, "car-3") then RetourneOption = "-4"
if TrouveMot(liste, "car-2") then RetourneOption = "-2"
if TrouveMot(liste, "car-1") then RetourneOption = "-1"
if TrouveMot(liste, "car+1") then RetourneOption = "3"
if TrouveMot(liste, "car+2") then RetourneOption = "5"
if TrouveMot(liste, "car+3") then RetourneOption = "6"
if TrouveMot(liste, "car+4") then RetourneOption = "9"
case "trace"
RetourneOption = ""
if TrouveMot(liste, "trace") then RetourneOption = "trace"
case "animation"
RetourneOption = ""
if TrouveMot(liste, "anime") then RetourneOption = "anime"
if TrouveMot(liste, "oscille") then RetourneOption = "oscille"
case "opacite"
RetourneOption = "0"
if TrouveMot(liste, "plein0") then RetourneOption = "0"
if TrouveMot(liste, "plein10") then RetourneOption = "10"
if TrouveMot(liste, "plein20") then RetourneOption = "20"
if TrouveMot(liste, "plein30") then RetourneOption = "30"
if TrouveMot(liste, "plein40") then RetourneOption = "40"
if TrouveMot(liste, "plein50") then RetourneOption = "50"
if TrouveMot(liste, "plein60") then RetourneOption = "60"
if TrouveMot(liste, "plein70") then RetourneOption = "70"
if TrouveMot(liste, "plein80") then RetourneOption = "80"
if TrouveMot(liste, "plein90") then RetourneOption = "90"
if TrouveMot(liste, "plein100") then RetourneOption = "100"
if TrouveMot(liste, "plein") then RetourneOption = "100"
case "rentrant"
RetourneOption = ""
if TrouveMot(liste, "r") then RetourneOption = "r"
case "code"
RetourneOption = ""
if TrouveMot(liste, "/") then RetourneOption = "/"
if TrouveMot(liste, "//") then RetourneOption = "//"
if TrouveMot(liste, "///") then RetourneOption = "///"
if TrouveMot(liste, "\") then RetourneOption = "\"
if TrouveMot(liste, "\\") then RetourneOption = "\\"
if TrouveMot(liste, "\\\") then RetourneOption = "\\\"
if TrouveMot(liste, "x") then RetourneOption = "x"
if TrouveMot(liste, "o") then RetourneOption = "o"
case "sens"
RetourneOption = "direct"
if TrouveMot(liste, "indirect") then RetourneOption = "indirect"
case "nom"
RetourneOption = "nom"
if TrouveMot(liste, "sansnom") then RetourneOption = "sansnom"
case "style"
RetourneOption = "1"
for i = 0 to 9
if TrouveMot(liste, trim(str(i))) then RetourneOption = trim(str(i))
next i
case "visibilite"
RetourneOption = "v"
if TrouveMot(liste, "i") or TrouveMot(liste, "invisible") then RetourneOption = "i"
if TrouveMot(liste, "v") or TrouveMot(liste, "visible") then RetourneOption = "v"
case "position"
RetourneOption = "0;0"
a = instr(1, liste, "(")
b = instr(1, liste, ")")
if a > 0 and b > 0 then
uTexte = mid(liste, a + 1, b - a - 1)
RemplaceTexte(uTexte, ",", ";")
RetourneOption = uTexte
end if
case "sprepere"
RetourneOption = "0"
if TrouveMot(liste, "0") then RetourneOption = "0"
if TrouveMot(liste, "1") then RetourneOption = "1"
if TrouveMot(liste, "2") then RetourneOption = "2"
if TrouveMot(liste, "3") then RetourneOption = "3"
case "tprepere"
RetourneOption = "10"
if TrouveMot(liste, "petit") then RetourneOption = "10"
if TrouveMot(liste, "moyen") then RetourneOption = "12"
if TrouveMot(liste, "grand") then RetourneOption = "14"
case "grepere"
RetourneOption = "1"
if TrouveMot(liste, "num1") then RetourneOption = "1"
if TrouveMot(liste, "num2") then RetourneOption = "2"
if TrouveMot(liste, "num5") then RetourneOption = "5"
if TrouveMot(liste, "num10") then RetourneOption = "10"
case "couleur", "crepere"
if nom = "couleur" then
RetourneOption = OOoTep_couleurdutrait
else
RetourneOption = OOoTep_couleurdutrait
end if
if TrouveMot(liste, "bleu") then RetourneOption = RetourneCouleur("bleu")
if TrouveMot(liste, "bleuciel") then RetourneOption = RetourneCouleur("bleuciel")
if TrouveMot(liste, "bleuocean") then RetourneOption = RetourneCouleur("bleuocean")
if TrouveMot(liste, "bleufonce") then RetourneOption = RetourneCouleur("bleufonce")
if TrouveMot(liste, "jaune") then RetourneOption = RetourneCouleur("jaune")
if TrouveMot(liste, "jauneclair") then RetourneOption = RetourneCouleur("jauneclair")
if TrouveMot(liste, "jaunepaille") then RetourneOption = RetourneCouleur("jaunepaille")
if TrouveMot(liste, "blanc") then RetourneOption = RetourneCouleur("blanc")
if TrouveMot(liste, "orange") then RetourneOption = RetourneCouleur("orange")
if TrouveMot(liste, "noir") then RetourneOption = RetourneCouleur("noir")
if TrouveMot(liste, "gris") then RetourneOption = RetourneCouleur("grisfonce")
if TrouveMot(liste, "grisclair") then RetourneOption = RetourneCouleur("grisclair")
if TrouveMot(liste, "grisfonce") then RetourneOption = RetourneCouleur("grisfonce")
if TrouveMot(liste, "rouge") then RetourneOption = RetourneCouleur("rouge")
if TrouveMot(liste, "rougefonce") then RetourneOption = RetourneCouleur("rougefonce")
if TrouveMot(liste, "rougeclair") then RetourneOption = RetourneCouleur("rougeclair")
if TrouveMot(liste, "vert") then RetourneOption = RetourneCouleur("vert")
if TrouveMot(liste, "vertfonce") then RetourneOption = RetourneCouleur("vertfonce")
if TrouveMot(liste, "vertclair") then RetourneOption = RetourneCouleur("vertclair")
if TrouveMot(liste, "vertpale") then RetourneOption = RetourneCouleur("vertpale")
if TrouveMot(liste, "violet") then RetourneOption = RetourneCouleur("violet")
if TrouveMot(liste, "violetfonce") then RetourneOption = RetourneCouleur("violetfonce")
if TrouveMot(liste, "marron") then RetourneOption = RetourneCouleur("marron")
if TrouveMot(liste, "marronfonce") then RetourneOption = RetourneCouleur("marronfonce")
if TrouveMot(liste, "rose") then RetourneOption = RetourneCouleur("rose")
if TrouveMot(liste, "saumon") then RetourneOption = RetourneCouleur("saumon")
if TrouveMot(liste, "sapin") then RetourneOption = RetourneCouleur("sapin")
if TrouveMot(liste, "brique") then RetourneOption = RetourneCouleur("brique")
if TrouveMot(liste, "kaki") then RetourneOption = RetourneCouleur("kaki")
if TrouveMot(liste, "kakiclair") then RetourneOption = RetourneCouleur("kakiclair")
if TrouveMot(liste, "cyan") then RetourneOption = RetourneCouleur("cyan")
if TrouveMot(liste, "magenta") then RetourneOption = RetourneCouleur("magenta")
a = instr(1, liste, "0x")
if a > 0 then RetourneOption = RetourneCouleur(mid(liste, a, 8))
case "police"
RetourneOption = ""
if TrouveMot(liste, "gras") then RetourneOption = "gras"
if TrouveMot(liste, "italique") then
if RetourneOption = "gras" then
RetourneOption = "gras et italique"
else
RetourneOption = "italique"
end if
end if
case "point"
RetourneOption = "croix2"
if TrouveMot(liste, "croix0") then RetourneOption = "croix0"
if TrouveMot(liste, "croix1") then RetourneOption = "croix1"
if TrouveMot(liste, "croix2") then RetourneOption = "croix2"
if TrouveMot(liste, "croix3") then RetourneOption = "croix3"
if TrouveMot(liste, "rond1") then RetourneOption = "rond1"
if TrouveMot(liste, "rond2") then RetourneOption = "rond2"
if TrouveMot(liste, "rond3") then RetourneOption = "rond3"
case "quadrant"
RetourneOption = "1"
if TrouveMot(liste, "q0") then RetourneOption = "0"
if TrouveMot(liste, "q2") then RetourneOption = "2"
if TrouveMot(liste, "q3") then RetourneOption = "3"
if TrouveMot(liste, "q4") then RetourneOption = "4"
End Select
end function
Function RetourneVariable(unTexte as String, Optional options as String) as String
Dim i as Integer
Dim ndec as String
Dim param() as String
if IsMissing(options) then options = ""
RetourneVariable = unTexte
i = ChercheObjet(unTexte)
if i <> - 1 then
if Sorte(i) = TEP_VARIABLE then
ndec = RetourneOption(options, "decimale")
if ndec <> "" then
RetourneVariable = int(val(Parametres(i)) * (10^val(ndec))) / (10^val(ndec))
else
RetourneVariable = Parametres(i)
end if
end if
if Sorte(i) = TEP_REEL then
ChargeParametre(Parametres(i), param(), ";")
RetourneVariable = param(ubound(param()))
end if
End if
End Function
function TrouveMot(liste as string, mot as string) as Boolean
dim cav as string, cap as string
dim a
TrouveMot = False
a = instr(1, liste, mot)
while((a > 0) and not TrouveMot)
if a = 1 then
cav = ""
else
cav = mid(liste, a - 1, 1)
end if
if a + len(mot) = len(liste) + 1 then
cap = ""
else
cap = mid(liste, a + len(mot), 1)
end if
if (cav = "" or cav = " " or cav = ";") and (cap = "" or cap = " " or cap = ";") then TrouveMot = True
a = instr(a + 1, liste, mot)
wend
end function
Function LoadDialog(Libname as String, DialogName as String) ', Optional oLibContainer) rem charge une boite de dialogue
Dim oLib, oLibDialog, oRuntimeDialog, oDialogModel, oVar, oVar1 as Object
DialogLibraries.LoadLibrary(LibName)
oLib = DialogLibraries.GetByName(Libname)
oLibDialog = oLib.GetByName(DialogName)
oRuntimeDialog = CreateUnoDialog(oLibDialog)
oDialogModel = oRuntimeDialog.Model
LoadDialog() = oRuntimeDialog
End Function
</script:module>
|