home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1994 March / Source_Code_CD-ROM_Walnut_Creek_March_1994.iso / compsrcs / x / volume19 / xephem / part16 < prev    next >
Encoding:
Text File  |  1993-05-15  |  77.2 KB  |  3,301 lines

  1. Newsgroups: comp.sources.x
  2. From: ecdowney@pobox.cca.cr.rockwell.com (Elwood Downey)
  3. Subject: v19i104:  xephem - astronomical ephemeris program, Part16/21
  4. Message-ID: <1993May10.221222.9390@sparky.imd.sterling.com>
  5. X-Md4-Signature: 5f93851abcc7f29fa8b420ad5b4ace3b
  6. Date: Mon, 10 May 1993 22:12:22 GMT
  7. Approved: chris@sparky.imd.sterling.com
  8.  
  9. Submitted-by: ecdowney@pobox.cca.cr.rockwell.com (Elwood Downey)
  10. Posting-number: Volume 19, Issue 104
  11. Archive-name: xephem/part16
  12. Environment: X11r4, OSF/Motif
  13. Supersedes: xephem: Volume 16, Issue 112-134
  14.  
  15. #! /bin/sh
  16. # This is a shell archive.  Remove anything before this line, then feed it
  17. # into a shell via "sh file" or similar.  To overwrite existing files,
  18. # type "sh file -c".
  19. # The tool that generated this appeared in the comp.sources.unix newsgroup;
  20. # send mail to comp-sources-unix@uunet.uu.net if you want that tool.
  21. # Contents:  earthmap.c earthmenu.c srchmenu.c
  22. # Wrapped by chris@nova on Mon May 10 16:41:51 1993
  23. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  24. echo If this archive is complete, you will see the following message:
  25. echo '          "shar: End of archive 16 (of 21)."'
  26. if test -f 'earthmap.c' -a "${1}" != "-c" ; then 
  27.   echo shar: Will not clobber existing file \"'earthmap.c'\"
  28. else
  29.   echo shar: Extracting \"'earthmap.c'\" \(28806 characters\)
  30.   sed "s/^X//" >'earthmap.c' <<'END_OF_FILE'
  31. X#include "map.h"
  32. X
  33. Xstatic MCoord ec0[] = {
  34. X    {-140,  60},
  35. X    {-132,  57},
  36. X    {-131,  56},
  37. X    {-134,  57},
  38. X    {-136,  59},
  39. X    {-137,  58},
  40. X    {-140,  60},
  41. X    {-147,  60},
  42. X    {-150,  60},
  43. X    {-149,  61},
  44. X    {-154,  59},
  45. X    {-157,  57},
  46. X    {-162,  55},
  47. X    {-158,  58},
  48. X    {-162,  58},
  49. X    {-165,  60},
  50. X    {-165,  63},
  51. X    {-161,  64},
  52. X    {-168,  65},
  53. X    {-163,  66},
  54. X    {-162,  67},
  55. X    {-167,  68},
  56. X    {-160,  70},
  57. X    {-154,  71},
  58. X    {-148,  70},
  59. X    {-142,  70},
  60. X    {-141,  70},
  61. X};
  62. Xstatic MCoord ec1[] = {
  63. X    {-153,  58},
  64. X    {-153,  58},
  65. X};
  66. Xstatic MCoord ec2[] = {
  67. X    {-153,  58},
  68. X    {-152,  57},
  69. X    {-153,  58},
  70. X};
  71. Xstatic MCoord ec3[] = {
  72. X    {-167,  54},
  73. X    {-167,  54},
  74. X};
  75. Xstatic MCoord ec4[] = {
  76. X    {-168,  54},
  77. X    {-168,  53},
  78. X};
  79. Xstatic MCoord ec5[] = {
  80. X    {-171,  53},
  81. X    {-171,  53},
  82. X};
  83. Xstatic MCoord ec6[] = {
  84. X    {-174,  52},
  85. X    {-174,  52},
  86. X};
  87. Xstatic MCoord ec7[] = {
  88. X    {-177,  52},
  89. X    {-177,  52},
  90. X};
  91. Xstatic MCoord ec8[] = {
  92. X    {-178,  52},
  93. X    {-177,  52},
  94. X};
  95. Xstatic MCoord ec9[] = {
  96. X    {-178,  52},
  97. X};
  98. Xstatic MCoord ec10[] = {
  99. X    { 177,  52},
  100. X    { 177,  52},
  101. X};
  102. Xstatic MCoord ec11[] = {
  103. X    { 172,  53},
  104. X    { 173,  53},
  105. X};
  106. Xstatic MCoord ec12[] = {
  107. X    {-141,  60},
  108. X    {-133,  59},
  109. X    {-131,  55},
  110. X    {-129,  54},
  111. X    {-127,  52},
  112. X    {-127,  51},
  113. X    {-124,  50},
  114. X    {-123,  49},
  115. X};
  116. Xstatic MCoord ec13[] = {
  117. X    { -92,  48},
  118. X    { -88,  49},
  119. X    { -83,  46},
  120. X    { -82,  45},
  121. X    { -82,  42},
  122. X    { -77,  44},
  123. X    { -70,  47},
  124. X    { -66,  45},
  125. X    { -66,  44},
  126. X    { -61,  45},
  127. X    { -65,  47},
  128. X    { -64,  49},
  129. X    { -71,  47},
  130. X    { -67,  49},
  131. X    { -60,  50},
  132. X    { -56,  52},
  133. X    { -59,  54},
  134. X    { -58,  54},
  135. X    { -61,  55},
  136. X    { -62,  57},
  137. X    { -64,  59},
  138. X    { -67,  58},
  139. X    { -70,  60},
  140. X    { -71,  61},
  141. X    { -78,  62},
  142. X    { -77,  60},
  143. X    { -77,  56},
  144. X    { -79,  52},
  145. X    { -82,  53},
  146. X    { -87,  56},
  147. X    { -92,  57},
  148. X    { -96,  59},
  149. X    { -93,  62},
  150. X    { -91,  63},
  151. X    { -96,  64},
  152. X    { -90,  64},
  153. X    { -89,  65},
  154. X    { -87,  66},
  155. X    { -85,  67},
  156. X    { -82,  68},
  157. X    { -83,  70},
  158. X    { -86,  68},
  159. X    { -88,  68},
  160. X    { -91,  69},
  161. X    { -92,  70},
  162. X    { -93,  71},
  163. X    { -97,  71},
  164. X    { -93,  70},
  165. X    { -94,  68},
  166. X    { -96,  67},
  167. X    { -99,  68},
  168. X    {-102,  68},
  169. X    {-108,  68},
  170. X    {-106,  68},
  171. X    {-108,  67},
  172. X    {-111,  68},
  173. X    {-114,  68},
  174. X    {-121,  69},
  175. X    {-124,  69},
  176. X    {-129,  71},
  177. X    {-132,  69},
  178. X    {-131,  70},
  179. X    {-136,  69},
  180. X    {-140,  69},
  181. X    {-141,  70},
  182. X};
  183. Xstatic MCoord ec14[] = {
  184. X    {-123,  48},
  185. X    {-128,  51},
  186. X    {-123,  48},
  187. X};
  188. Xstatic MCoord ec15[] = {
  189. X    {-132,  53},
  190. X    {-132,  53},
  191. X};
  192. Xstatic MCoord ec16[] = {
  193. X    {-133,  53},
  194. X    {-132,  54},
  195. X    {-133,  53},
  196. X};
  197. Xstatic MCoord ec17[] = {
  198. X    { -55,  52},
  199. X    { -55,  50},
  200. X    { -54,  47},
  201. X    { -53,  46},
  202. X    { -56,  47},
  203. X    { -58,  48},
  204. X    { -58,  50},
  205. X    { -55,  52},
  206. X};
  207. Xstatic MCoord ec18[] = {
  208. X    { -61,  49},
  209. X    { -62,  49},
  210. X    { -61,  49},
  211. X};
  212. Xstatic MCoord ec19[] = {
  213. X    { -63,  47},
  214. X    { -64,  47},
  215. X    { -63,  47},
  216. X};
  217. Xstatic MCoord ec20[] = {
  218. X    { -60,  46},
  219. X    { -60,  47},
  220. X};
  221. Xstatic MCoord ec21[] = {
  222. X    {-122,  49},
  223. X    {-124,  47},
  224. X    {-125,  42},
  225. X    {-123,  38},
  226. X    {-122,  37},
  227. X    {-118,  33},
  228. X    {-117,  33},
  229. X};
  230. Xstatic MCoord ec22[] = {
  231. X    { -98,  26},
  232. X    { -96,  29},
  233. X    { -91,  29},
  234. X    { -87,  30},
  235. X    { -83,  28},
  236. X    { -80,  27},
  237. X    { -81,  32},
  238. X    { -77,  35},
  239. X    { -76,  38},
  240. X    { -76,  38},
  241. X    { -71,  42},
  242. X    { -69,  44},
  243. X    { -68,  47},
  244. X    { -73,  45},
  245. X    { -79,  43},
  246. X    { -83,  43},
  247. X    { -83,  45},
  248. X    { -86,  44},
  249. X    { -88,  43},
  250. X    { -86,  46},
  251. X    { -87,  47},
  252. X    { -91,  47},
  253. X    { -90,  48},
  254. X};
  255. Xstatic MCoord ec23[] = {
  256. X    { -72,  41},
  257. X    { -72,  41},
  258. X};
  259. Xstatic MCoord ec24[] = {
  260. X    { -81,  27},
  261. X    { -81,  27},
  262. X};
  263. Xstatic MCoord ec25[] = {
  264. X    {-113,  42},
  265. X    {-113,  42},
  266. X};
  267. Xstatic MCoord ec26[] = {
  268. X    {-156,  20},
  269. X    {-156,  20},
  270. X};
  271. Xstatic MCoord ec27[] = {
  272. X    {-157,  21},
  273. X    {-157,  21},
  274. X};
  275. Xstatic MCoord ec28[] = {
  276. X    {-157,  21},
  277. X    {-157,  21},
  278. X};
  279. Xstatic MCoord ec29[] = {
  280. X    {-158,  21},
  281. X};
  282. Xstatic MCoord ec30[] = {
  283. X    {-160,  22},
  284. X};
  285. Xstatic MCoord ec31[] = {
  286. X    {-117,  66},
  287. X    {-120,  65},
  288. X    {-124,  65},
  289. X    {-124,  66},
  290. X    {-119,  66},
  291. X    {-117,  66},
  292. X};
  293. Xstatic MCoord ec32[] = {
  294. X    {-121,  64},
  295. X    {-115,  62},
  296. X    {-109,  63},
  297. X    {-113,  61},
  298. X    {-119,  61},
  299. X    {-117,  61},
  300. X    {-116,  63},
  301. X    {-119,  64},
  302. X    {-121,  64},
  303. X};
  304. Xstatic MCoord ec33[] = {
  305. X    {-112,  58},
  306. X    {-109,  59},
  307. X    {-104,  59},
  308. X    {-103,  57},
  309. X    {-102,  59},
  310. X    {-105,  59},
  311. X    {-111,  59},
  312. X    {-112,  59},
  313. X};
  314. Xstatic MCoord ec34[] = {
  315. X    { -99,  50},
  316. X    {-100,  52},
  317. X    {-100,  51},
  318. X    { -99,  50},
  319. X};
  320. Xstatic MCoord ec35[] = {
  321. X    { -97,  50},
  322. X    { -97,  54},
  323. X    { -99,  53},
  324. X    { -97,  51},
  325. X    { -97,  50},
  326. X};
  327. Xstatic MCoord ec36[] = {
  328. X    { -95,  49},
  329. X    { -92,  50},
  330. X    { -94,  49},
  331. X    { -95,  49},
  332. X};
  333. Xstatic MCoord ec37[] = {
  334. X    { -80,  56},
  335. X    { -79,  56},
  336. X    { -80,  56},
  337. X};
  338. Xstatic MCoord ec38[] = {
  339. X    {-104,  59},
  340. X    {-104,  59},
  341. X};
  342. Xstatic MCoord ec39[] = {
  343. X    {-102,  58},
  344. X    {-102,  58},
  345. X    {-102,  58},
  346. X};
  347. Xstatic MCoord ec40[] = {
  348. X    {-102,  56},
  349. X    { -98,  57},
  350. X    {-101,  56},
  351. X    {-102,  56},
  352. X};
  353. Xstatic MCoord ec41[] = {
  354. X    {-117,  32},
  355. X    {-115,  28},
  356. X    {-113,  25},
  357. X    {-111,  24},
  358. X    {-114,  30},
  359. X    {-113,  30},
  360. X    {-110,  26},
  361. X    {-106,  22},
  362. X    {-102,  18},
  363. X    { -96,  16},
  364. X    { -92,  15},
  365. X};
  366. Xstatic MCoord ec42[] = {
  367. X    { -88,  17},
  368. X    { -87,  21},
  369. X    { -92,  19},
  370. X    { -97,  20},
  371. X    { -98,  26},
  372. X};
  373. Xstatic MCoord ec43[] = {
  374. X    { -92,  15},
  375. X    { -87,  12},
  376. X    { -83,   9},
  377. X    { -80,   9},
  378. X    { -77,   8},
  379. X    { -82,   9},
  380. X    { -84,  13},
  381. X    { -86,  16},
  382. X    { -88,  16},
  383. X};
  384. Xstatic MCoord ec44[] = {
  385. X    { -78,   7},
  386. X    { -79,   1},
  387. X    { -81,  -4},
  388. X    { -76, -15},
  389. X    { -70, -19},
  390. X    { -71, -26},
  391. X    { -71, -32},
  392. X    { -73, -37},
  393. X    { -73, -42},
  394. X    { -73, -46},
  395. X    { -74, -48},
  396. X    { -74, -52},
  397. X    { -71, -54},
  398. X    { -69, -51},
  399. X    { -68, -47},
  400. X    { -63, -43},
  401. X    { -62, -40},
  402. X    { -57, -37},
  403. X    { -53, -34},
  404. X    { -51, -32},
  405. X    { -48, -25},
  406. X    { -41, -22},
  407. X    { -39, -15},
  408. X    { -35,  -8},
  409. X    { -42,  -3},
  410. X    { -48,  -2},
  411. X    { -48,  -2},
  412. X    { -51,   0},
  413. X    { -54,   5},
  414. X    { -61,   8},
  415. X    { -64,  10},
  416. X    { -71,  11},
  417. X    { -71,  12},
  418. X    { -76,   9},
  419. X    { -78,   7},
  420. X};
  421. Xstatic MCoord ec45[] = {
  422. X    { -69, -53},
  423. X    { -66, -55},
  424. X    { -70, -55},
  425. X    { -71, -54},
  426. X    { -69, -53},
  427. X};
  428. Xstatic MCoord ec46[] = {
  429. X    { -59, -52},
  430. X    { -59, -52},
  431. X};
  432. Xstatic MCoord ec47[] = {
  433. X    { -59, -52},
  434. X    { -59, -52},
  435. X};
  436. Xstatic MCoord ec48[] = {
  437. X    { -84,  21},
  438. X    { -74,  20},
  439. X    { -79,  21},
  440. X    { -84,  22},
  441. X    { -84,  21},
  442. X};
  443. Xstatic MCoord ec49[] = {
  444. X    { -67,  18},
  445. X    { -67,  18},
  446. X};
  447. Xstatic MCoord ec50[] = {
  448. X    { -78,  17},
  449. X    { -78,  17},
  450. X};
  451. Xstatic MCoord ec51[] = {
  452. X    { -74,  18},
  453. X    { -70,  19},
  454. X    { -71,  18},
  455. X    { -74,  18},
  456. X};
  457. Xstatic MCoord ec52[] = {
  458. X    { -85,  74},
  459. X    { -86,  71},
  460. X    { -85,  72},
  461. X    { -85,  73},
  462. X    { -81,  73},
  463. X    { -78,  72},
  464. X    { -75,  73},
  465. X    { -74,  72},
  466. X    { -73,  71},
  467. X    { -71,  71},
  468. X    { -70,  70},
  469. X    { -68,  70},
  470. X    { -66,  69},
  471. X    { -67,  68},
  472. X    { -64,  68},
  473. X    { -62,  67},
  474. X    { -63,  65},
  475. X    { -66,  66},
  476. X    { -67,  65},
  477. X    { -64,  63},
  478. X    { -67,  63},
  479. X    { -69,  62},
  480. X    { -72,  64},
  481. X    { -77,  64},
  482. X    { -73,  66},
  483. X    { -70,  67},
  484. X    { -72,  67},
  485. X    { -76,  68},
  486. X    { -78,  70},
  487. X    { -82,  70},
  488. X    { -88,  70},
  489. X    { -90,  71},
  490. X    { -85,  74},
  491. X};
  492. Xstatic MCoord ec53[] = {
  493. X    { -81,  76},
  494. X    { -84,  76},
  495. X    { -89,  76},
  496. X    { -85,  77},
  497. X    { -85,  78},
  498. X    { -87,  79},
  499. X    { -83,  79},
  500. X    { -85,  80},
  501. X    { -81,  80},
  502. X    { -76,  81},
  503. X    { -83,  81},
  504. X    { -83,  81},
  505. X    { -87,  81},
  506. X    { -89,  81},
  507. X    { -90,  81},
  508. X    { -89,  82},
  509. X    { -87,  82},
  510. X    { -81,  82},
  511. X    { -80,  83},
  512. X    { -78,  83},
  513. X    { -76,  83},
  514. X    { -71,  83},
  515. X    { -65,  83},
  516. X    { -63,  82},
  517. X    { -68,  81},
  518. X    { -69,  80},
  519. X    { -71,  80},
  520. X    { -74,  79},
  521. X    { -75,  79},
  522. X    { -75,  79},
  523. X    { -76,  78},
  524. X    { -81,  77},
  525. X    { -78,  77},
  526. X    { -81,  76},
  527. X};
  528. Xstatic MCoord ec54[] = {
  529. X    { -93,  74},
  530. X    { -92,  73},
  531. X    { -95,  73},
  532. X    { -93,  74},
  533. X};
  534. Xstatic MCoord ec55[] = {
  535. X    { -95,  77},
  536. X    { -90,  76},
  537. X    { -89,  75},
  538. X    { -82,  76},
  539. X    { -79,  75},
  540. X    { -86,  74},
  541. X    { -92,  75},
  542. X    { -96,  77},
  543. X    { -95,  77},
  544. X};
  545. Xstatic MCoord ec56[] = {
  546. X    {-100,  74},
  547. X    { -98,  73},
  548. X    { -98,  71},
  549. X    {-102,  73},
  550. X    {-101,  73},
  551. X    {-100,  74},
  552. X};
  553. Xstatic MCoord ec57[] = {
  554. X    {-108,  73},
  555. X    {-105,  71},
  556. X    {-102,  70},
  557. X    {-104,  69},
  558. X    {-107,  69},
  559. X    {-114,  69},
  560. X    {-114,  70},
  561. X    {-116,  70},
  562. X    {-116,  71},
  563. X    {-117,  72},
  564. X    {-114,  72},
  565. X    {-110,  72},
  566. X    {-107,  72},
  567. X    {-107,  73},
  568. X};
  569. Xstatic MCoord ec58[] = {
  570. X    {-121,  74},
  571. X    {-118,  73},
  572. X    {-123,  71},
  573. X    {-123,  74},
  574. X    {-121,  74},
  575. X};
  576. Xstatic MCoord ec59[] = {
  577. X    {-109,  77},
  578. X    {-106,  76},
  579. X    {-107,  75},
  580. X    {-113,  74},
  581. X    {-112,  75},
  582. X    {-116,  75},
  583. X    {-115,  76},
  584. X    {-111,  76},
  585. X    {-110,  76},
  586. X    {-109,  77},
  587. X};
  588. Xstatic MCoord ec60[] = {
  589. X    {-116,  77},
  590. X    {-118,  76},
  591. X    {-121,  76},
  592. X    {-116,  77},
  593. X};
  594. Xstatic MCoord ec61[] = {
  595. X    {-110,  78},
  596. X    {-112,  78},
  597. X    {-110,  78},
  598. X};
  599. Xstatic MCoord ec62[] = {
  600. X    {-110,  78},
  601. X    {-112,  78},
  602. X    {-110,  78},
  603. X};
  604. Xstatic MCoord ec63[] = {
  605. X    { -98,  77},
  606. X    { -99,  75},
  607. X    {-101,  76},
  608. X    { -99,  76},
  609. X    { -98,  77},
  610. X};
  611. Xstatic MCoord ec64[] = {
  612. X    { -95,  76},
  613. X    { -95,  76},
  614. X};
  615. Xstatic MCoord ec65[] = {
  616. X    {-104,  79},
  617. X    { -99,  78},
  618. X    {-103,  78},
  619. X    {-104,  79},
  620. X};
  621. Xstatic MCoord ec66[] = {
  622. X    { -94,  78},
  623. X    { -94,  78},
  624. X};
  625. Xstatic MCoord ec67[] = {
  626. X    { -97,  79},
  627. X    { -97,  78},
  628. X    { -97,  78},
  629. X};
  630. Xstatic MCoord ec68[] = {
  631. X    { -85,  66},
  632. X    { -82,  64},
  633. X    { -85,  63},
  634. X    { -85,  66},
  635. X};
  636. Xstatic MCoord ec69[] = {
  637. X    { -82,  63},
  638. X    { -82,  63},
  639. X};
  640. Xstatic MCoord ec70[] = {
  641. X    { -80,  62},
  642. X    { -80,  62},
  643. X};
  644. Xstatic MCoord ec71[] = {
  645. X    { -44,  60},
  646. X    { -45,  61},
  647. X    { -48,  61},
  648. X    { -50,  62},
  649. X    { -51,  64},
  650. X    { -51,  65},
  651. X    { -53,  66},
  652. X    { -54,  67},
  653. X    { -54,  68},
  654. X    { -52,  69},
  655. X    { -52,  70},
  656. X    { -52,  71},
  657. X    { -55,  71},
  658. X    { -55,  73},
  659. X    { -57,  75},
  660. X    { -62,  76},
  661. X    { -66,  76},
  662. X    { -71,  77},
  663. X    { -67,  78},
  664. X    { -71,  78},
  665. X    { -65,  80},
  666. X    { -63,  81},
  667. X    { -57,  82},
  668. X    { -48,  82},
  669. X    { -42,  83},
  670. X    { -38,  84},
  671. X    { -24,  83},
  672. X    { -26,  82},
  673. X    { -26,  81},
  674. X    { -14,  81},
  675. X    { -17,  80},
  676. X    { -20,  79},
  677. X    { -19,  78},
  678. X    { -22,  76},
  679. X    { -21,  75},
  680. X    { -22,  74},
  681. X    { -24,  74},
  682. X    { -27,  73},
  683. X    { -25,  73},
  684. X    { -22,  72},
  685. X    { -25,  71},
  686. X    { -27,  71},
  687. X    { -27,  70},
  688. X    { -24,  69},
  689. X    { -28,  68},
  690. X    { -32,  69},
  691. X    { -35,  66},
  692. X    { -38,  66},
  693. X    { -40,  65},
  694. X    { -40,  64},
  695. X    { -42,  63},
  696. X    { -43,  61},
  697. X    { -43,  60},
  698. X    { -44,  60},
  699. X};
  700. Xstatic MCoord ec72[] = {
  701. X    { -16,  66},
  702. X    { -15,  64},
  703. X    { -20,  63},
  704. X    { -22,  64},
  705. X    { -21,  65},
  706. X    { -23,  66},
  707. X    { -22,  66},
  708. X    { -19,  66},
  709. X    { -16,  66},
  710. X};
  711. Xstatic MCoord ec73[] = {
  712. X    {   1,  51},
  713. X    {  -2,  55},
  714. X    {  -3,  58},
  715. X    {  -5,  58},
  716. X    {  -6,  56},
  717. X    {  -3,  55},
  718. X    {  -5,  53},
  719. X    {  -3,  52},
  720. X    {  -4,  50},
  721. X    {   1,  51},
  722. X    {   1,  51},
  723. X};
  724. Xstatic MCoord ec74[] = {
  725. X    {  -7,  55},
  726. X    { -10,  53},
  727. X    {  -9,  52},
  728. X    {  -6,  55},
  729. X    {  -7,  55},
  730. X};
  731. Xstatic MCoord ec75[] = {
  732. X    {  -1,  61},
  733. X    {  -1,  60},
  734. X};
  735. Xstatic MCoord ec76[] = {
  736. X    {  -6,  58},
  737. X    {  -6,  58},
  738. X};
  739. Xstatic MCoord ec77[] = {
  740. X    {  -6,  58},
  741. X    {  -6,  58},
  742. X};
  743. Xstatic MCoord ec78[] = {
  744. X    {  -7,  58},
  745. X};
  746. Xstatic MCoord ec79[] = {
  747. X    {  -7,  57},
  748. X};
  749. Xstatic MCoord ec80[] = {
  750. X    {  -7,  57},
  751. X};
  752. Xstatic MCoord ec81[] = {
  753. X    {  -6,  56},
  754. X};
  755. Xstatic MCoord ec82[] = {
  756. X    {  -5,  56},
  757. X};
  758. Xstatic MCoord ec83[] = {
  759. X    {  -4,  54},
  760. X    {  -4,  54},
  761. X};
  762. Xstatic MCoord ec84[] = {
  763. X    {  -8,  71},
  764. X    {  -8,  71},
  765. X};
  766. Xstatic MCoord ec85[] = {
  767. X    {  17,  80},
  768. X    {  22,  78},
  769. X    {  17,  76},
  770. X    {  16,  77},
  771. X    {  16,  78},
  772. X    {  17,  80},
  773. X};
  774. Xstatic MCoord ec86[] = {
  775. X    {  15,  79},
  776. X    {  16,  79},
  777. X    {  14,  78},
  778. X    {  14,  78},
  779. X    {  13,  79},
  780. X    {  15,  79},
  781. X};
  782. Xstatic MCoord ec87[] = {
  783. X    {  22,  78},
  784. X    {  22,  78},
  785. X};
  786. Xstatic MCoord ec88[] = {
  787. X    {  22,  78},
  788. X    {  24,  77},
  789. X    {  22,  78},
  790. X    {  23,  78},
  791. X};
  792. Xstatic MCoord ec89[] = {
  793. X    {  24,  80},
  794. X    {  28,  80},
  795. X    {  21,  79},
  796. X    {  19,  79},
  797. X    {  21,  80},
  798. X    {  23,  80},
  799. X};
  800. Xstatic MCoord ec90[] = {
  801. X    {  47,  80},
  802. X    {  43,  80},
  803. X    {  47,  80},
  804. X};
  805. Xstatic MCoord ec91[] = {
  806. X    {  50,  80},
  807. X    {  51,  80},
  808. X    {  48,  80},
  809. X    {  50,  80},
  810. X};
  811. Xstatic MCoord ec92[] = {
  812. X    {  62,  80},
  813. X    {  62,  80},
  814. X};
  815. Xstatic MCoord ec93[] = {
  816. X    {  65,  81},
  817. X    {  64,  81},
  818. X    {  65,  81},
  819. X};
  820. Xstatic MCoord ec94[] = {
  821. X    {  -5,  36},
  822. X    {   4,  37},
  823. X    {  10,  37},
  824. X    {  11,  34},
  825. X    {  20,  30},
  826. X    {  23,  32},
  827. X    {  32,  31},
  828. X    {  36,  24},
  829. X    {  40,  15},
  830. X    {  43,  11},
  831. X    {  52,  11},
  832. X    {  50,   7},
  833. X    {  43,  -1},
  834. X    {  39,  -8},
  835. X    {  40, -13},
  836. X    {  38, -18},
  837. X    {  35, -23},
  838. X    {  33, -28},
  839. X    {  27, -34},
  840. X    {  20, -36},
  841. X    {  18, -31},
  842. X    {  12, -19},
  843. X    {  14, -13},
  844. X    {  12,  -6},
  845. X    {  10,   0},
  846. X    {   7,   4},
  847. X    {   2,   5},
  848. X    {  -5,   5},
  849. X    { -12,   7},
  850. X    { -16,  11},
  851. X    { -16,  16},
  852. X    { -16,  22},
  853. X    { -13,  27},
  854. X    { -10,  31},
  855. X    {  -5,  36},
  856. X};
  857. Xstatic MCoord ec95[] = {
  858. X    {  34,   0},
  859. X    {  33,  -3},
  860. X    {  33,   0},
  861. X    {  34,   0},
  862. X};
  863. Xstatic MCoord ec96[] = {
  864. X    {  49, -12},
  865. X    {  49, -19},
  866. X    {  44, -25},
  867. X    {  44, -20},
  868. X    {  46, -16},
  869. X    {  48, -14},
  870. X    {  49, -12},
  871. X};
  872. Xstatic MCoord ec97[] = {
  873. X    {  32,  31},
  874. X    {  36,  35},
  875. X    {  33,  36},
  876. X    {  28,  37},
  877. X    {  27,  39},
  878. X    {  32,  41},
  879. X    {  39,  40},
  880. X    {  40,  43},
  881. X    {  40,  46},
  882. X    {  35,  45},
  883. X    {  34,  45},
  884. X    {  30,  45},
  885. X    {  29,  41},
  886. X    {  27,  40},
  887. X    {  24,  40},
  888. X    {  24,  37},
  889. X    {  22,  37},
  890. X    {  19,  42},
  891. X    {  15,  44},
  892. X    {  15,  42},
  893. X    {  18,  40},
  894. X    {  16,  39},
  895. X    {  12,  42},
  896. X    {   7,  43},
  897. X    {   3,  41},
  898. X    {  -1,  37},
  899. X    {  -6,  37},
  900. X    {  -9,  40},
  901. X    {  -7,  43},
  902. X    {  -1,  46},
  903. X    {  -4,  48},
  904. X    {   0,  49},
  905. X    {   4,  51},
  906. X    {   6,  53},
  907. X    {   8,  56},
  908. X    {  12,  55},
  909. X    {  12,  54},
  910. X    {  17,  54},
  911. X    {  21,  56},
  912. X    {  25,  57},
  913. X    {  29,  59},
  914. X    {  24,  60},
  915. X    {  22,  63},
  916. X    {  24,  65},
  917. X    {  19,  63},
  918. X    {  19,  60},
  919. X    {  18,  59},
  920. X    {  15,  56},
  921. X    {  12,  58},
  922. X    {   8,  58},
  923. X    {   6,  59},
  924. X    {   7,  61},
  925. X    {   8,  62},
  926. X    {  10,  63},
  927. X    {  13,  65},
  928. X    {  15,  67},
  929. X    {  19,  69},
  930. X    {  22,  70},
  931. X    {  25,  70},
  932. X    {  26,  70},
  933. X    {  29,  70},
  934. X    {  30,  70},
  935. X    {  34,  69},
  936. X    {  42,  67},
  937. X    {  35,  66},
  938. X    {  33,  66},
  939. X    {  35,  64},
  940. X    {  38,  64},
  941. X    {  42,  64},
  942. X    {  45,  66},
  943. X    {  45,  68},
  944. X    {  46,  67},
  945. X    {  52,  68},
  946. X    {  54,  68},
  947. X    {  60,  68},
  948. X    {  65,  69},
  949. X    {  69,  69},
  950. X    {  68,  71},
  951. X    {  73,  72},
  952. X    {  74,  68},
  953. X    {  69,  66},
  954. X    {  73,  66},
  955. X    {  78,  68},
  956. X    {  81,  67},
  957. X    {  75,  69},
  958. X    {  75,  72},
  959. X    {  79,  71},
  960. X    {  78,  72},
  961. X    {  83,  71},
  962. X    {  84,  70},
  963. X    {  81,  73},
  964. X    {  87,  74},
  965. X    {  88,  75},
  966. X    {  90,  75},
  967. X};
  968. Xstatic MCoord ec98[] = {
  969. X    {  68,  77},
  970. X    {  66,  76},
  971. X    {  59,  74},
  972. X    {  55,  73},
  973. X    {  57,  74},
  974. X    {  59,  75},
  975. X    {  64,  76},
  976. X    {  68,  77},
  977. X};
  978. Xstatic MCoord ec99[] = {
  979. X    {  53,  73},
  980. X    {  58,  70},
  981. X    {  55,  71},
  982. X    {  53,  72},
  983. X    {  54,  73},
  984. X};
  985. Xstatic MCoord ec100[] = {
  986. X    {  90,  21},
  987. X    {  82,  16},
  988. X    {  80,  12},
  989. X    {  76,   9},
  990. X    {  73,  17},
  991. X    {  72,  20},
  992. X    {  69,  22},
  993. X    {  65,  24},
  994. X    {  58,  25},
  995. X    {  53,  26},
  996. X    {  50,  29},
  997. X    {  51,  25},
  998. X    {  54,  23},
  999. X    {  59,  23},
  1000. X    {  58,  19},
  1001. X    {  53,  16},
  1002. X    {  47,  13},
  1003. X    {  43,  15},
  1004. X    {  40,  20},
  1005. X    {  37,  26},
  1006. X    {  33,  28},
  1007. X    {  33,  31},
  1008. X};
  1009. Xstatic MCoord ec101[] = {
  1010. X    {  52,  47},
  1011. X    {  52,  45},
  1012. X    {  53,  42},
  1013. X    {  53,  40},
  1014. X    {  54,  38},
  1015. X    {  49,  38},
  1016. X    {  48,  43},
  1017. X    {  49,  46},
  1018. X    {  52,  47},
  1019. X};
  1020. Xstatic MCoord ec102[] = {
  1021. X    {  62,  46},
  1022. X    {  60,  43},
  1023. X    {  60,  46},
  1024. X    {  62,  46},
  1025. X};
  1026. Xstatic MCoord ec103[] = {
  1027. X    {  80,  46},
  1028. X    {  74,  44},
  1029. X    {  79,  46},
  1030. X    {  80,  46},
  1031. X};
  1032. Xstatic MCoord ec104[] = {
  1033. X    {  77,  42},
  1034. X    {  77,  42},
  1035. X};
  1036. Xstatic MCoord ec105[] = {
  1037. X    {  35,  35},
  1038. X    {  35,  35},
  1039. X    {  35,  35},
  1040. X};
  1041. Xstatic MCoord ec106[] = {
  1042. X    {  24,  35},
  1043. X    {  24,  35},
  1044. X    {  24,  35},
  1045. X};
  1046. Xstatic MCoord ec107[] = {
  1047. X    {  16,  38},
  1048. X    {  13,  38},
  1049. X    {  16,  38},
  1050. X};
  1051. Xstatic MCoord ec108[] = {
  1052. X    {  10,  41},
  1053. X    {   8,  40},
  1054. X    {   9,  41},
  1055. X};
  1056. Xstatic MCoord ec109[] = {
  1057. X    {  10,  43},
  1058. X    {  10,  42},
  1059. X};
  1060. Xstatic MCoord ec110[] = {
  1061. X    {  81,   9},
  1062. X    {  80,   6},
  1063. X    {  80,   8},
  1064. X};
  1065. Xstatic MCoord ec111[] = {
  1066. X    {  11,  57},
  1067. X    {  11,  57},
  1068. X};
  1069. Xstatic MCoord ec112[] = {
  1070. X    { -78,  25},
  1071. X    { -78,  24},
  1072. X};
  1073. Xstatic MCoord ec113[] = {
  1074. X    { -78,  24},
  1075. X    { -77,  24},
  1076. X};
  1077. Xstatic MCoord ec114[] = {
  1078. X    { -76,  24},
  1079. X    { -75,  24},
  1080. X};
  1081. Xstatic MCoord ec115[] = {
  1082. X    { -91,   0},
  1083. X    { -92,   0},
  1084. X};
  1085. Xstatic MCoord ec116[] = {
  1086. X    { -60,  47},
  1087. X    { -61,  46},
  1088. X};
  1089. Xstatic MCoord ec117[] = {
  1090. X    { -64,  49},
  1091. X    { -63,  49},
  1092. X};
  1093. Xstatic MCoord ec118[] = {
  1094. X    { 143, -11},
  1095. X    { 146, -16},
  1096. X    { 150, -22},
  1097. X    { 153, -27},
  1098. X    { 151, -35},
  1099. X    { 146, -39},
  1100. X    { 140, -38},
  1101. X    { 137, -35},
  1102. X    { 136, -35},
  1103. X    { 132, -31},
  1104. X    { 122, -34},
  1105. X    { 116, -33},
  1106. X    { 114, -26},
  1107. X    { 115, -21},
  1108. X    { 122, -18},
  1109. X    { 125, -15},
  1110. X    { 128, -15},
  1111. X    { 132, -11},
  1112. X    { 136, -12},
  1113. X    { 138, -16},
  1114. X    { 142, -11},
  1115. X};
  1116. Xstatic MCoord ec119[] = {
  1117. X    { 145, -41},
  1118. X    { 148, -42},
  1119. X    { 146, -43},
  1120. X    { 146, -41},
  1121. X};
  1122. Xstatic MCoord ec120[] = {
  1123. X    { 173, -34},
  1124. X    { 176, -38},
  1125. X    { 177, -39},
  1126. X    { 175, -38},
  1127. X    { 173, -34},
  1128. X};
  1129. Xstatic MCoord ec121[] = {
  1130. X    { 172, -41},
  1131. X    { 173, -44},
  1132. X    { 168, -46},
  1133. X    { 170, -43},
  1134. X    { 174, -41},
  1135. X};
  1136. Xstatic MCoord ec122[] = {
  1137. X    { 151, -10},
  1138. X    { 143,  -8},
  1139. X    { 138,  -7},
  1140. X    { 132,  -3},
  1141. X    { 131,  -1},
  1142. X    { 134,  -3},
  1143. X    { 141,  -3},
  1144. X    { 148,  -8},
  1145. X    { 151, -10},
  1146. X};
  1147. Xstatic MCoord ec123[] = {
  1148. X    { 117,   7},
  1149. X    { 118,   1},
  1150. X    { 114,  -3},
  1151. X    { 109,  -1},
  1152. X    { 113,   3},
  1153. X    { 117,   7},
  1154. X};
  1155. Xstatic MCoord ec124[] = {
  1156. X    {  95,   6},
  1157. X    { 102,   1},
  1158. X    { 106,  -3},
  1159. X    { 101,  -3},
  1160. X    {  95,   6},
  1161. X};
  1162. Xstatic MCoord ec125[] = {
  1163. X    { 141,  42},
  1164. X    { 141,  36},
  1165. X    { 137,  35},
  1166. X    { 134,  35},
  1167. X    { 132,  35},
  1168. X    { 137,  37},
  1169. X    { 140,  40},
  1170. X    { 141,  41},
  1171. X};
  1172. Xstatic MCoord ec126[] = {
  1173. X    { 134,  34},
  1174. X    { 131,  32},
  1175. X    { 129,  33},
  1176. X    { 134,  34},
  1177. X};
  1178. Xstatic MCoord ec127[] = {
  1179. X    { 142,  46},
  1180. X    { 144,  43},
  1181. X    { 140,  42},
  1182. X    { 142,  45},
  1183. X    { 142,  46},
  1184. X};
  1185. Xstatic MCoord ec128[] = {
  1186. X    { 143,  54},
  1187. X    { 144,  49},
  1188. X    { 142,  46},
  1189. X    { 142,  51},
  1190. X    { 143,  54},
  1191. X};
  1192. Xstatic MCoord ec129[] = {
  1193. X    { 122,  25},
  1194. X    { 121,  25},
  1195. X    { 122,  26},
  1196. X};
  1197. Xstatic MCoord ec130[] = {
  1198. X    { 111,  20},
  1199. X    { 109,  20},
  1200. X    { 111,  20},
  1201. X};
  1202. Xstatic MCoord ec131[] = {
  1203. X    { 107,  -6},
  1204. X    { 114,  -8},
  1205. X    { 109,  -8},
  1206. X    { 107,  -6},
  1207. X};
  1208. Xstatic MCoord ec132[] = {
  1209. X    { 164, -20},
  1210. X    { 164, -20},
  1211. X};
  1212. Xstatic MCoord ec133[] = {
  1213. X    { 179, -17},
  1214. X    { 179, -17},
  1215. X};
  1216. Xstatic MCoord ec134[] = {
  1217. X    { 179, -16},
  1218. X    { 179, -16},
  1219. X};
  1220. Xstatic MCoord ec135[] = {
  1221. X    {-173, -13},
  1222. X    {-173, -14},
  1223. X};
  1224. Xstatic MCoord ec136[] = {
  1225. X    { 122,  19},
  1226. X    { 123,  14},
  1227. X    { 121,  14},
  1228. X    { 120,  16},
  1229. X    { 122,  18},
  1230. X};
  1231. Xstatic MCoord ec137[] = {
  1232. X    { 125,  10},
  1233. X    { 126,   6},
  1234. X    { 122,   7},
  1235. X    { 125,   9},
  1236. X};
  1237. Xstatic MCoord ec138[] = {
  1238. X    { 120,  11},
  1239. X    { 119,  10},
  1240. X    { 120,  11},
  1241. X};
  1242. Xstatic MCoord ec139[] = {
  1243. X    {  90,  22},
  1244. X    {  94,  18},
  1245. X    {  98,  15},
  1246. X    {  98,   9},
  1247. X    { 103,   2},
  1248. X    { 100,   8},
  1249. X    { 100,  14},
  1250. X    { 104,  10},
  1251. X    { 107,  10},
  1252. X    { 108,  16},
  1253. X    { 109,  22},
  1254. X    { 113,  22},
  1255. X    { 119,  25},
  1256. X    { 121,  30},
  1257. X    { 121,  33},
  1258. X    { 122,  37},
  1259. X    { 118,  38},
  1260. X    { 122,  40},
  1261. X    { 125,  39},
  1262. X    { 126,  35},
  1263. X    { 128,  38},
  1264. X    { 130,  42},
  1265. X    { 139,  47},
  1266. X    { 141,  52},
  1267. X    { 137,  54},
  1268. X    { 141,  58},
  1269. X    { 149,  59},
  1270. X    { 154,  59},
  1271. X    { 157,  62},
  1272. X    { 160,  61},
  1273. X    { 164,  62},
  1274. X    { 156,  58},
  1275. X    { 156,  51},
  1276. X    { 162,  55},
  1277. X    { 163,  57},
  1278. X    { 164,  60},
  1279. X    { 170,  60},
  1280. X    { 177,  63},
  1281. X    { 178,  64},
  1282. X    { 179,  65},
  1283. X};
  1284. Xstatic MCoord ec140[] = {
  1285. X    {-180,  65},
  1286. X    {-177,  66},
  1287. X    {-173,  65},
  1288. X    {-171,  66},
  1289. X    {-176,  68},
  1290. X    {-179,  68},
  1291. X};
  1292. Xstatic MCoord ec141[] = {
  1293. X    { 179,  69},
  1294. X    { 170,  70},
  1295. X    { 168,  70},
  1296. X    { 160,  70},
  1297. X    { 151,  71},
  1298. X    { 147,  72},
  1299. X    { 146,  72},
  1300. X    { 140,  72},
  1301. X    { 135,  72},
  1302. X    { 131,  71},
  1303. X    { 126,  72},
  1304. X    { 129,  73},
  1305. X    { 123,  73},
  1306. X    { 113,  73},
  1307. X    { 110,  74},
  1308. X    { 108,  74},
  1309. X    { 113,  76},
  1310. X    { 106,  76},
  1311. X    { 104,  78},
  1312. X    { 100,  76},
  1313. X    {  95,  76},
  1314. X    {  90,  76},
  1315. X};
  1316. Xstatic MCoord ec142[] = {
  1317. X    { 102,  79},
  1318. X    { 101,  78},
  1319. X    { 101,  79},
  1320. X};
  1321. Xstatic MCoord ec143[] = {
  1322. X    {  94,  79},
  1323. X    { 100,  79},
  1324. X    {  95,  79},
  1325. X    {  95,  80},
  1326. X    {  97,  80},
  1327. X};
  1328. Xstatic MCoord ec144[] = {
  1329. X    {  95,  81},
  1330. X    {  92,  80},
  1331. X    {  95,  81},
  1332. X};
  1333. Xstatic MCoord ec145[] = {
  1334. X    {  91,  80},
  1335. X    {  91,  80},
  1336. X};
  1337. Xstatic MCoord ec146[] = {
  1338. X    { 139,  76},
  1339. X    { 145,  75},
  1340. X    { 140,  75},
  1341. X    { 137,  75},
  1342. X    { 138,  76},
  1343. X};
  1344. Xstatic MCoord ec147[] = {
  1345. X    { 146,  75},
  1346. X    { 148,  75},
  1347. X    { 146,  75},
  1348. X};
  1349. Xstatic MCoord ec148[] = {
  1350. X    { 141,  74},
  1351. X    { 141,  74},
  1352. X};
  1353. Xstatic MCoord ec149[] = {
  1354. X    {   0, -72},
  1355. X    {   7, -71},
  1356. X    {  15, -70},
  1357. X    {  25, -71},
  1358. X    {  33, -69},
  1359. X    {  38, -70},
  1360. X    {  43, -68},
  1361. X    {  47, -67},
  1362. X    {  49, -67},
  1363. X    {  53, -66},
  1364. X    {  58, -67},
  1365. X    {  64, -68},
  1366. X    {  71, -68},
  1367. X    {  69, -70},
  1368. X    {  76, -69},
  1369. X    {  88, -67},
  1370. X    {  95, -67},
  1371. X    { 102, -66},
  1372. X    { 111, -66},
  1373. X    { 119, -67},
  1374. X    { 126, -66},
  1375. X    { 133, -66},
  1376. X    { 140, -67},
  1377. X    { 147, -68},
  1378. X    { 154, -69},
  1379. X    { 160, -70},
  1380. X    { 164, -71},
  1381. X    { 170, -72},
  1382. X    { 166, -75},
  1383. X    { 164, -78},
  1384. X    { 162, -79},
  1385. X    { 167, -83},
  1386. X    { 176, -84},
  1387. X};
  1388. Xstatic MCoord ec150[] = {
  1389. X    {-179, -84},
  1390. X    {-148, -85},
  1391. X    {-153, -81},
  1392. X    {-154, -79},
  1393. X    {-151, -77},
  1394. X    {-147, -76},
  1395. X    {-138, -75},
  1396. X    {-132, -75},
  1397. X    {-123, -74},
  1398. X    {-115, -74},
  1399. X    {-112, -75},
  1400. X    {-105, -75},
  1401. X    {-101, -74},
  1402. X    {-101, -73},
  1403. X    {-100, -73},
  1404. X    { -93, -73},
  1405. X    { -85, -73},
  1406. X    { -80, -73},
  1407. X    { -78, -73},
  1408. X    { -72, -73},
  1409. X    { -68, -71},
  1410. X    { -68, -69},
  1411. X    { -67, -67},
  1412. X    { -64, -65},
  1413. X    { -59, -64},
  1414. X    { -60, -64},
  1415. X    { -62, -66},
  1416. X    { -62, -67},
  1417. X    { -66, -68},
  1418. X    { -64, -69},
  1419. X    { -62, -71},
  1420. X    { -61, -73},
  1421. X    { -61, -74},
  1422. X    { -63, -76},
  1423. X    { -76, -77},
  1424. X    { -83, -77},
  1425. X    { -74, -81},
  1426. X    { -56, -82},
  1427. X    { -42, -82},
  1428. X    { -32, -80},
  1429. X    { -34, -79},
  1430. X    { -32, -77},
  1431. X    { -26, -76},
  1432. X    { -17, -73},
  1433. X    { -11, -72},
  1434. X    {  -9, -72},
  1435. X    {  -5, -71},
  1436. X    {  -1, -72},
  1437. X    {   0, -72},
  1438. X};
  1439. Xstatic MCoord ec151[] = {
  1440. X    { 165, -78},
  1441. X    { 171, -77},
  1442. X    { 180, -78},
  1443. X};
  1444. Xstatic MCoord ec152[] = {
  1445. X    {-179, -78},
  1446. X    {-166, -78},
  1447. X    {-158, -78},
  1448. X};
  1449. Xstatic MCoord ec153[] = {
  1450. X    { -59, -65},
  1451. X    { -61, -69},
  1452. X    { -61, -72},
  1453. X};
  1454. Xstatic MCoord ec154[] = {
  1455. X    { -62, -75},
  1456. X    { -52, -77},
  1457. X    { -42, -78},
  1458. X    { -36, -78},
  1459. X};
  1460. Xstatic MCoord ec155[] = {
  1461. X    { -35, -78},
  1462. X    { -26, -76},
  1463. X    { -19, -73},
  1464. X    { -12, -72},
  1465. X    {  -6, -71},
  1466. X    {  -1, -69},
  1467. X    {   5, -70},
  1468. X    {  11, -70},
  1469. X    {  17, -70},
  1470. X    {  25, -70},
  1471. X    {  32, -69},
  1472. X    {  34, -70},
  1473. X};
  1474. Xstatic MCoord ec156[] = {
  1475. X    {  71, -69},
  1476. X    {  74, -70},
  1477. X};
  1478. Xstatic MCoord ec157[] = {
  1479. X    {  81, -68},
  1480. X    {  85, -66},
  1481. X    {  89, -67},
  1482. X};
  1483. Xstatic MCoord ec158[] = {
  1484. X    {-136, -75},
  1485. X    {-124, -73},
  1486. X    {-117, -74},
  1487. X    {-110, -75},
  1488. X    {-105, -75},
  1489. X    {-106, -75},
  1490. X};
  1491. Xstatic MCoord ec159[] = {
  1492. X    { -69, -70},
  1493. X    { -71, -73},
  1494. X    { -71, -72},
  1495. X    { -75, -71},
  1496. X    { -72, -71},
  1497. X    { -70, -69},
  1498. X    { -69, -70},
  1499. X};
  1500. Xstatic MCoord ec160[] = {
  1501. X    { -49, -78},
  1502. X    { -45, -79},
  1503. X    { -44, -80},
  1504. X    { -59, -80},
  1505. X    { -49, -78},
  1506. X    { -48, -78},
  1507. X};
  1508. Xstatic MCoord ec161[] = {
  1509. X    { -58, -80},
  1510. X    { -63, -80},
  1511. X    { -58, -80},
  1512. X};
  1513. Xstatic MCoord ec162[] = {
  1514. X    {-164, -79},
  1515. X    {-161, -80},
  1516. X    {-164, -79},
  1517. X};
  1518. Xstatic MCoord ec163[] = {
  1519. X    {  67,  67},
  1520. X    {  67,  67},
  1521. X};
  1522. XMRegion ereg[] = {
  1523. X    {(char *)0, ec0, 27},
  1524. X    {(char *)0, ec1, 2},
  1525. X    {(char *)0, ec2, 3},
  1526. X    {(char *)0, ec3, 2},
  1527. X    {(char *)0, ec4, 2},
  1528. X    {(char *)0, ec5, 2},
  1529. X    {(char *)0, ec6, 2},
  1530. X    {(char *)0, ec7, 2},
  1531. X    {(char *)0, ec8, 2},
  1532. X    {(char *)0, ec9, 1},
  1533. X    {(char *)0, ec10, 2},
  1534. X    {(char *)0, ec11, 2},
  1535. X    {(char *)0, ec12, 8},
  1536. X    {(char *)0, ec13, 65},
  1537. X    {(char *)0, ec14, 3},
  1538. X    {(char *)0, ec15, 2},
  1539. X    {(char *)0, ec16, 3},
  1540. X    {(char *)0, ec17, 8},
  1541. X    {(char *)0, ec18, 3},
  1542. X    {(char *)0, ec19, 3},
  1543. X    {(char *)0, ec20, 2},
  1544. X    {(char *)0, ec21, 7},
  1545. X    {(char *)0, ec22, 23},
  1546. X    {(char *)0, ec23, 2},
  1547. X    {(char *)0, ec24, 2},
  1548. X    {(char *)0, ec25, 2},
  1549. X    {(char *)0, ec26, 2},
  1550. X    {(char *)0, ec27, 2},
  1551. X    {(char *)0, ec28, 2},
  1552. X    {(char *)0, ec29, 1},
  1553. X    {(char *)0, ec30, 1},
  1554. X    {(char *)0, ec31, 6},
  1555. X    {(char *)0, ec32, 9},
  1556. X    {(char *)0, ec33, 8},
  1557. X    {(char *)0, ec34, 4},
  1558. X    {(char *)0, ec35, 5},
  1559. X    {(char *)0, ec36, 4},
  1560. X    {(char *)0, ec37, 3},
  1561. X    {(char *)0, ec38, 2},
  1562. X    {(char *)0, ec39, 3},
  1563. X    {(char *)0, ec40, 4},
  1564. X    {(char *)0, ec41, 11},
  1565. X    {(char *)0, ec42, 5},
  1566. X    {(char *)0, ec43, 9},
  1567. X    {(char *)0, ec44, 35},
  1568. X    {(char *)0, ec45, 5},
  1569. X    {(char *)0, ec46, 2},
  1570. X    {(char *)0, ec47, 2},
  1571. X    {(char *)0, ec48, 5},
  1572. X    {(char *)0, ec49, 2},
  1573. X    {(char *)0, ec50, 2},
  1574. X    {(char *)0, ec51, 4},
  1575. X    {(char *)0, ec52, 33},
  1576. X    {(char *)0, ec53, 34},
  1577. X    {(char *)0, ec54, 4},
  1578. X    {(char *)0, ec55, 9},
  1579. X    {(char *)0, ec56, 6},
  1580. X    {(char *)0, ec57, 14},
  1581. X    {(char *)0, ec58, 5},
  1582. X    {(char *)0, ec59, 10},
  1583. X    {(char *)0, ec60, 4},
  1584. X    {(char *)0, ec61, 3},
  1585. X    {(char *)0, ec62, 3},
  1586. X    {(char *)0, ec63, 5},
  1587. X    {(char *)0, ec64, 2},
  1588. X    {(char *)0, ec65, 4},
  1589. X    {(char *)0, ec66, 2},
  1590. X    {(char *)0, ec67, 3},
  1591. X    {(char *)0, ec68, 4},
  1592. X    {(char *)0, ec69, 2},
  1593. X    {(char *)0, ec70, 2},
  1594. X    {(char *)0, ec71, 54},
  1595. X    {(char *)0, ec72, 9},
  1596. X    {(char *)0, ec73, 11},
  1597. X    {(char *)0, ec74, 5},
  1598. X    {(char *)0, ec75, 2},
  1599. X    {(char *)0, ec76, 2},
  1600. X    {(char *)0, ec77, 2},
  1601. X    {(char *)0, ec78, 1},
  1602. X    {(char *)0, ec79, 1},
  1603. X    {(char *)0, ec80, 1},
  1604. X    {(char *)0, ec81, 1},
  1605. X    {(char *)0, ec82, 1},
  1606. X    {(char *)0, ec83, 2},
  1607. X    {(char *)0, ec84, 2},
  1608. X    {(char *)0, ec85, 6},
  1609. X    {(char *)0, ec86, 6},
  1610. X    {(char *)0, ec87, 2},
  1611. X    {(char *)0, ec88, 4},
  1612. X    {(char *)0, ec89, 6},
  1613. X    {(char *)0, ec90, 3},
  1614. X    {(char *)0, ec91, 4},
  1615. X    {(char *)0, ec92, 2},
  1616. X    {(char *)0, ec93, 3},
  1617. X    {(char *)0, ec94, 35},
  1618. X    {(char *)0, ec95, 4},
  1619. X    {(char *)0, ec96, 7},
  1620. X    {(char *)0, ec97, 94},
  1621. X    {(char *)0, ec98, 8},
  1622. X    {(char *)0, ec99, 5},
  1623. X    {(char *)0, ec100, 22},
  1624. X    {(char *)0, ec101, 9},
  1625. X    {(char *)0, ec102, 4},
  1626. X    {(char *)0, ec103, 4},
  1627. X    {(char *)0, ec104, 2},
  1628. X    {(char *)0, ec105, 3},
  1629. X    {(char *)0, ec106, 3},
  1630. X    {(char *)0, ec107, 3},
  1631. X    {(char *)0, ec108, 3},
  1632. X    {(char *)0, ec109, 2},
  1633. X    {(char *)0, ec110, 3},
  1634. X    {(char *)0, ec111, 2},
  1635. X    {(char *)0, ec112, 2},
  1636. X    {(char *)0, ec113, 2},
  1637. X    {(char *)0, ec114, 2},
  1638. X    {(char *)0, ec115, 2},
  1639. X    {(char *)0, ec116, 2},
  1640. X    {(char *)0, ec117, 2},
  1641. X    {(char *)0, ec118, 21},
  1642. X    {(char *)0, ec119, 4},
  1643. X    {(char *)0, ec120, 5},
  1644. X    {(char *)0, ec121, 5},
  1645. X    {(char *)0, ec122, 9},
  1646. X    {(char *)0, ec123, 6},
  1647. X    {(char *)0, ec124, 5},
  1648. X    {(char *)0, ec125, 8},
  1649. X    {(char *)0, ec126, 4},
  1650. X    {(char *)0, ec127, 5},
  1651. X    {(char *)0, ec128, 5},
  1652. X    {(char *)0, ec129, 3},
  1653. X    {(char *)0, ec130, 3},
  1654. X    {(char *)0, ec131, 4},
  1655. X    {(char *)0, ec132, 2},
  1656. X    {(char *)0, ec133, 2},
  1657. X    {(char *)0, ec134, 2},
  1658. X    {(char *)0, ec135, 2},
  1659. X    {(char *)0, ec136, 5},
  1660. X    {(char *)0, ec137, 4},
  1661. X    {(char *)0, ec138, 3},
  1662. X    {(char *)0, ec139, 40},
  1663. X    {(char *)0, ec140, 6},
  1664. X    {(char *)0, ec141, 22},
  1665. X    {(char *)0, ec142, 3},
  1666. X    {(char *)0, ec143, 5},
  1667. X    {(char *)0, ec144, 3},
  1668. X    {(char *)0, ec145, 2},
  1669. X    {(char *)0, ec146, 5},
  1670. X    {(char *)0, ec147, 3},
  1671. X    {(char *)0, ec148, 2},
  1672. X    {(char *)0, ec149, 33},
  1673. X    {(char *)0, ec150, 49},
  1674. X    {(char *)0, ec151, 3},
  1675. X    {(char *)0, ec152, 3},
  1676. X    {(char *)0, ec153, 3},
  1677. X    {(char *)0, ec154, 4},
  1678. X    {(char *)0, ec155, 12},
  1679. X    {(char *)0, ec156, 2},
  1680. X    {(char *)0, ec157, 3},
  1681. X    {(char *)0, ec158, 6},
  1682. X    {(char *)0, ec159, 7},
  1683. X    {(char *)0, ec160, 6},
  1684. X    {(char *)0, ec161, 3},
  1685. X    {(char *)0, ec162, 3},
  1686. X    {(char *)0, ec163, 2},
  1687. X};
  1688. X
  1689. Xint nereg = (sizeof(ereg)/sizeof(ereg[0]));
  1690. END_OF_FILE
  1691.   if test 28806 -ne `wc -c <'earthmap.c'`; then
  1692.     echo shar: \"'earthmap.c'\" unpacked with wrong size!
  1693.   fi
  1694.   # end of 'earthmap.c'
  1695. fi
  1696. if test -f 'earthmenu.c' -a "${1}" != "-c" ; then 
  1697.   echo shar: Will not clobber existing file \"'earthmenu.c'\"
  1698. else
  1699.   echo shar: Extracting \"'earthmenu.c'\" \(16271 characters\)
  1700.   sed "s/^X//" >'earthmenu.c' <<'END_OF_FILE'
  1701. X/* code to manage the stuff on the "earthmap" menu.
  1702. X */
  1703. X
  1704. X#include <stdio.h>
  1705. X#include <ctype.h>
  1706. X#include <math.h>
  1707. X#if defined(__STDC__)
  1708. X#include <stdlib.h>
  1709. X#endif
  1710. X#include <X11/Xlib.h>
  1711. X#include <Xm/Xm.h>
  1712. X#include <Xm/Form.h>
  1713. X#include <Xm/Frame.h>
  1714. X#include <Xm/Label.h>
  1715. X#include <Xm/PushB.h>
  1716. X#include <Xm/RowColumn.h>
  1717. X#include <Xm/DrawingA.h>
  1718. X#include <Xm/Separator.h>
  1719. X#include <Xm/ToggleB.h>
  1720. X#include "astro.h"
  1721. X#include "circum.h"
  1722. X#include "map.h"
  1723. X
  1724. X#if defined(__STDC__) || defined(__cplusplus)
  1725. X#define P_(s) s
  1726. X#else
  1727. X#define P_(s) ()
  1728. X#endif
  1729. X
  1730. Xextern double mjd_day P_((double jd));
  1731. Xextern double mjd_hr P_((double jd));
  1732. Xextern int any_ison P_((void));
  1733. Xextern int obj_cir P_((Now *np, Obj *op));
  1734. Xextern void f_gangle P_((Widget w, double a));
  1735. Xextern void get_something P_((Widget w, char *resource, char *value));
  1736. Xextern void hlp_dialog P_((char *tag, char *deflt[], int ndeflt));
  1737. Xextern void precess P_((double mjd1, double mjd2, double *ra, double *dec));
  1738. Xextern void range P_((double *v, double r));
  1739. Xextern void register_selection P_((char *name));
  1740. Xextern void timestamp P_((Now *np, Widget w));
  1741. Xextern void utc_gst P_((double Mjd, double utc, double *gst));
  1742. X
  1743. Xvoid e_manage P_((void));
  1744. Xvoid e_update P_((Now *np, int force));
  1745. Xint e_ison P_((void));
  1746. Xvoid e_selection_mode P_((int whether));
  1747. Xvoid e_cursor P_((Cursor c));
  1748. Xstatic void e_create_form P_((void));
  1749. Xstatic void e_ll_cb P_((Widget w, XtPointer client, XtPointer call));
  1750. Xstatic void e_close_cb P_((Widget w, XtPointer client, XtPointer call));
  1751. Xstatic void e_help_cb P_((Widget w, XtPointer client, XtPointer call));
  1752. Xstatic void e_exp_cb P_((Widget w, XtPointer client, XtPointer call));
  1753. Xstatic void e_set_buttons P_((int whether));
  1754. Xstatic void e_subsolar P_((Now *np, double *latp, double *longp));
  1755. Xstatic void e_map P_((Now *np, double slat, double slong));
  1756. X
  1757. X#undef P_
  1758. X
  1759. X/* these are from earthmap.c */
  1760. Xextern MRegion ereg[];
  1761. Xextern int nereg;
  1762. X
  1763. Xextern Widget toplevel_w;
  1764. Xextern Now *mm_get_now();
  1765. X#define    XtD    XtDisplay(toplevel_w)
  1766. X
  1767. Xstatic int e_selecting;    /* set while our fields are being selected */
  1768. X
  1769. Xstatic Widget eform_w;    /* main form dialog */
  1770. Xstatic Widget e_long_w;    /* solar longitude numberic display widget */
  1771. Xstatic Widget e_lat_w;    /* solar latitude numberic display widget */
  1772. Xstatic Widget e_da_w;    /* map DrawingArea widget */
  1773. Xstatic Widget e_dt_w;    /* data/time stamp label widget */
  1774. X
  1775. X#define    DSIN(x)        sin(degrad(x))
  1776. X#define    DCOS(x)        cos(degrad(x))
  1777. X
  1778. Xvoid
  1779. Xe_manage()
  1780. X{
  1781. X    if (!eform_w)
  1782. X        e_create_form();
  1783. X
  1784. X    if (XtIsManaged(eform_w))
  1785. X        XtUnmanageChild(eform_w);
  1786. X    else {
  1787. X        XtManageChild(eform_w);
  1788. X        e_set_buttons(e_selecting);
  1789. X    }
  1790. X}
  1791. X
  1792. X/* display the map and lat/long info for circumstances described by *np..
  1793. X * don't bother with the computation of lat/long unless we are managed or
  1794. X *   someone cares.
  1795. X * don't bother with the map unless we are managed.
  1796. X */
  1797. Xvoid
  1798. Xe_update(np, force)
  1799. XNow *np;
  1800. Xint force;
  1801. X{
  1802. X    double slat, slong;
  1803. X
  1804. X    if (!eform_w)
  1805. X        return;
  1806. X    if (!XtIsManaged(eform_w) && !any_ison() && !force)
  1807. X        return;
  1808. X
  1809. X    e_subsolar (np, &slat, &slong);
  1810. X
  1811. X    if (XtIsManaged(eform_w))
  1812. X        e_map (np, slat, slong);
  1813. X
  1814. X    f_gangle (e_lat_w, slat);
  1815. X
  1816. X    /* we want to display +W in range of -PI..+PI */
  1817. X    slong = -slong;
  1818. X    range (&slong, 2*PI);
  1819. X    if (slong >= PI)
  1820. X        slong -= 2*PI;
  1821. X    f_gangle (e_long_w, slong);
  1822. X}
  1823. X
  1824. Xe_ison()
  1825. X{
  1826. X    return (eform_w && XtIsManaged(eform_w));
  1827. X}
  1828. X
  1829. X/* called by other menus as they want to hear from our buttons or not.
  1830. X * the ons and offs stack.
  1831. X */
  1832. Xvoid
  1833. Xe_selection_mode (whether)
  1834. Xint whether;
  1835. X{
  1836. X    e_selecting += whether ? 1 : -1;
  1837. X
  1838. X    if (e_ison())
  1839. X        if (whether && e_selecting == 1       /* first one to want on */
  1840. X        || !whether && e_selecting == 0 /* first one to want off */)
  1841. X        e_set_buttons (whether);
  1842. X}
  1843. X
  1844. Xvoid
  1845. Xe_cursor(c)
  1846. XCursor c;
  1847. X{
  1848. X    Window win;
  1849. X
  1850. X    if (eform_w && (win = XtWindow(eform_w))) {
  1851. X        Display *dsp = XtDisplay(eform_w);
  1852. X        if (c)
  1853. X        XDefineCursor(dsp, win, c);
  1854. X        else
  1855. X        XUndefineCursor(dsp, win);
  1856. X    }
  1857. X}
  1858. X
  1859. Xstatic void
  1860. Xe_create_form()
  1861. X{
  1862. X    static struct {
  1863. X        char *name;
  1864. X        void (*cb)();
  1865. X    } ctls[] = {
  1866. X        {"Close", e_close_cb},
  1867. X        {"Help", e_help_cb}
  1868. X    };
  1869. X    Widget w;
  1870. X    Widget fr_w;
  1871. X    Widget f_w;
  1872. X    Widget sep_w;
  1873. X    XmString str;
  1874. X    Arg args[20];
  1875. X    int n;
  1876. X    int i;
  1877. X
  1878. X    /* create form */
  1879. X    n = 0;
  1880. X    XtSetArg (args[n], XmNautoUnmanage, False); n++;
  1881. X    XtSetArg (args[n], XmNdefaultPosition, False); n++;
  1882. X    XtSetArg (args[n], XmNresizePolicy, XmRESIZE_NONE); n++;
  1883. X    XtSetArg (args[n], XmNhorizontalSpacing, 4); n++;
  1884. X    XtSetArg (args[n], XmNverticalSpacing, 4); n++;
  1885. X    eform_w = XmCreateFormDialog (toplevel_w, "Earth", args,n);
  1886. X
  1887. X    /* set some stuff in the parent DialogShell.
  1888. X     * setting XmNdialogTitle in the Form didn't work..
  1889. X     */
  1890. X    n = 0;
  1891. X    XtSetArg (args[n], XmNtitle, "xephem Earth subsolar view"); n++;
  1892. X    XtSetValues (XtParent(eform_w), args, n);
  1893. X
  1894. X    /* make the bottom control panel form */
  1895. X
  1896. X    n = 0;
  1897. X    XtSetArg (args[n], XmNbottomAttachment, XmATTACH_FORM); n++;
  1898. X    XtSetArg (args[n], XmNleftAttachment, XmATTACH_FORM); n++;
  1899. X    XtSetArg (args[n], XmNrightAttachment, XmATTACH_FORM); n++;
  1900. X    XtSetArg (args[n], XmNfractionBase, 9); n++;
  1901. X    XtSetArg (args[n], XmNverticalSpacing, 5); n++;
  1902. X    f_w = XmCreateForm (eform_w, "CtlF", args, n);
  1903. X    XtManageChild (f_w);
  1904. X
  1905. X        for (i = 0; i < XtNumber(ctls); i++) {
  1906. X        n = 0;
  1907. X        XtSetArg (args[n], XmNtopAttachment, XmATTACH_FORM); n++;
  1908. X        XtSetArg (args[n], XmNbottomAttachment, XmATTACH_FORM); n++;
  1909. X        XtSetArg (args[n], XmNleftAttachment, XmATTACH_POSITION); n++;
  1910. X        XtSetArg (args[n], XmNleftPosition, 1+i*4); n++;
  1911. X        XtSetArg (args[n], XmNrightAttachment, XmATTACH_POSITION); n++;
  1912. X        XtSetArg (args[n], XmNrightPosition, 4+i*4); n++;
  1913. X        w = XmCreatePushButton (f_w, ctls[i].name, args, n);
  1914. X        XtManageChild (w);
  1915. X        XtAddCallback (w, XmNactivateCallback, ctls[i].cb, NULL);
  1916. X        }
  1917. X
  1918. X    /* make a separator */
  1919. X
  1920. X    n = 0;
  1921. X    XtSetArg (args[n], XmNbottomAttachment, XmATTACH_WIDGET); n++;
  1922. X    XtSetArg (args[n], XmNbottomWidget, f_w); n++;
  1923. X    XtSetArg (args[n], XmNleftAttachment, XmATTACH_FORM); n++;
  1924. X    XtSetArg (args[n], XmNrightAttachment, XmATTACH_FORM); n++;
  1925. X    sep_w = XmCreateSeparator (eform_w, "Sep", args, n);
  1926. X    XtManageChild(sep_w);
  1927. X
  1928. X    /* make the "latitude" label and push button pair */
  1929. X
  1930. X    str = XmStringCreateLtoR("Latitude (degs, +N): ",
  1931. X                            XmSTRING_DEFAULT_CHARSET);
  1932. X    n = 0;
  1933. X    XtSetArg (args[n], XmNbottomAttachment, XmATTACH_WIDGET); n++;
  1934. X    XtSetArg (args[n], XmNbottomWidget, sep_w); n++;
  1935. X    XtSetArg (args[n], XmNleftAttachment, XmATTACH_FORM); n++;
  1936. X    XtSetArg (args[n], XmNalignment, XmALIGNMENT_BEGINNING); n++;
  1937. X    XtSetArg (args[n], XmNlabelString, str); n++;
  1938. X    w = XmCreateLabel (eform_w, "LatLbl", args, n);
  1939. X    XtManageChild (w);
  1940. X    XmStringFree(str);
  1941. X
  1942. X    str = XmStringCreateLtoR("-88:88:88",XmSTRING_DEFAULT_CHARSET); /*size*/
  1943. X    n = 0;
  1944. X    XtSetArg (args[n], XmNbottomAttachment, XmATTACH_WIDGET); n++;
  1945. X    XtSetArg (args[n], XmNbottomWidget, sep_w); n++;
  1946. X    XtSetArg (args[n], XmNrightAttachment, XmATTACH_FORM); n++;
  1947. X    XtSetArg (args[n], XmNleftAttachment, XmATTACH_WIDGET); n++;
  1948. X    XtSetArg (args[n], XmNleftWidget, w); n++;
  1949. X    XtSetArg (args[n], XmNalignment, XmALIGNMENT_END); n++;
  1950. X    XtSetArg (args[n], XmNlabelString, str); n++;
  1951. X    XtSetArg (args[n], XmNuserData, "Earth.Lat"); n++;
  1952. X    e_lat_w = XmCreatePushButton (eform_w, "LatVal", args, n);
  1953. X    XtAddCallback (e_lat_w, XmNactivateCallback, e_ll_cb, 0);
  1954. X    XtManageChild (e_lat_w);
  1955. X    XmStringFree(str);
  1956. X
  1957. X    /* make the "Longitude" label and push button pair */
  1958. X
  1959. X    str = XmStringCreateLtoR("Longitude (degs, +W): ",
  1960. X                            XmSTRING_DEFAULT_CHARSET);
  1961. X    n = 0;
  1962. X    XtSetArg (args[n], XmNbottomAttachment, XmATTACH_WIDGET); n++;
  1963. X    XtSetArg (args[n], XmNbottomWidget, e_lat_w); n++;
  1964. X    XtSetArg (args[n], XmNleftAttachment, XmATTACH_FORM); n++;
  1965. X    XtSetArg (args[n], XmNalignment, XmALIGNMENT_BEGINNING); n++;
  1966. X    XtSetArg (args[n], XmNlabelString, str); n++;
  1967. X    w = XmCreateLabel (eform_w, "LongLbl", args, n);
  1968. X    XtManageChild (w);
  1969. X    XmStringFree(str);
  1970. X
  1971. X    str = XmStringCreateLtoR("-188:88:88",XmSTRING_DEFAULT_CHARSET);/*size*/
  1972. X    n = 0;
  1973. X    XtSetArg (args[n], XmNbottomAttachment, XmATTACH_WIDGET); n++;
  1974. X    XtSetArg (args[n], XmNbottomWidget, e_lat_w); n++;
  1975. X    XtSetArg (args[n], XmNrightAttachment, XmATTACH_FORM); n++;
  1976. X    XtSetArg (args[n], XmNleftAttachment, XmATTACH_WIDGET); n++;
  1977. X    XtSetArg (args[n], XmNleftWidget, w); n++;
  1978. X    XtSetArg (args[n], XmNalignment, XmALIGNMENT_END); n++;
  1979. X    XtSetArg (args[n], XmNlabelString, str); n++;
  1980. X    XtSetArg (args[n], XmNuserData, "Earth.Long"); n++;
  1981. X    e_long_w = XmCreatePushButton (eform_w, "LongVal", args, n);
  1982. X    XtAddCallback (e_long_w, XmNactivateCallback, e_ll_cb, 0);
  1983. X    XtManageChild (e_long_w);
  1984. X    XmStringFree(str);
  1985. X
  1986. X    /* make the date/time indicator label */
  1987. X
  1988. X    n = 0;
  1989. X    XtSetArg (args[n], XmNbottomAttachment, XmATTACH_WIDGET); n++;
  1990. X    XtSetArg (args[n], XmNbottomWidget, e_long_w); n++;
  1991. X    XtSetArg (args[n], XmNleftAttachment, XmATTACH_FORM); n++;
  1992. X    XtSetArg (args[n], XmNrightAttachment, XmATTACH_FORM); n++;
  1993. X    XtSetArg (args[n], XmNalignment, XmALIGNMENT_CENTER); n++;
  1994. X    e_dt_w = XmCreateLabel (eform_w, "DTstamp", args, n);
  1995. X    XtManageChild (e_dt_w);
  1996. X
  1997. X    /* make a drawing area in a frame on top */
  1998. X
  1999. X    n = 0;
  2000. X    XtSetArg (args[n], XmNtopAttachment, XmATTACH_FORM); n++;
  2001. X    XtSetArg (args[n], XmNbottomAttachment, XmATTACH_WIDGET); n++;
  2002. X    XtSetArg (args[n], XmNbottomWidget, e_dt_w); n++;
  2003. X    XtSetArg (args[n], XmNleftAttachment, XmATTACH_FORM); n++;
  2004. X    XtSetArg (args[n], XmNrightAttachment, XmATTACH_FORM); n++;
  2005. X    XtSetArg (args[n], XmNshadowType, XmSHADOW_ETCHED_OUT); n++;
  2006. X    fr_w = XmCreateFrame (eform_w, "EarthFrame", args, n);
  2007. X    XtManageChild (fr_w);
  2008. X
  2009. X        n = 0;
  2010. X        e_da_w = XmCreateDrawingArea (fr_w, "Map", args, n);
  2011. X        XtAddCallback (e_da_w, XmNexposeCallback, e_exp_cb, NULL);
  2012. X        XtManageChild (e_da_w);
  2013. X}
  2014. X
  2015. X/* callback for when the lat/long buttons are activated. */
  2016. X/* ARGSUSED */
  2017. Xstatic void
  2018. Xe_ll_cb (w, client, call)
  2019. XWidget w;
  2020. XXtPointer client;
  2021. XXtPointer call;
  2022. X{
  2023. X    if (e_selecting) {
  2024. X        char *userD;
  2025. X        get_something (w, XmNuserData, (char *)&userD);
  2026. X        register_selection (userD);
  2027. X    }
  2028. X}
  2029. X
  2030. X/* callback for when the Close button is activated. */
  2031. X/* ARGSUSED */
  2032. Xstatic void
  2033. Xe_close_cb (w, client, call)
  2034. XWidget w;
  2035. XXtPointer client;
  2036. XXtPointer call;
  2037. X{
  2038. X    XtUnmanageChild (eform_w);
  2039. X}
  2040. X
  2041. X/* callback from the Help button
  2042. X */
  2043. X/* ARGSUSED */
  2044. Xstatic void
  2045. Xe_help_cb (w, client, call)
  2046. XWidget w;
  2047. XXtPointer client;
  2048. XXtPointer call;
  2049. X{
  2050. X    static char *msg[] = {
  2051. X"This is a simple schematic depiction of the Earth surface at the given time.",
  2052. X"The view is from directly over the spot where the Sun is currently over head.",
  2053. X};
  2054. X
  2055. X    hlp_dialog ("Earth", msg, XtNumber(msg));
  2056. X}
  2057. X
  2058. X/* called whenever the earth drawing area gets an expose.
  2059. X */
  2060. X/* ARGSUSED */
  2061. Xstatic void
  2062. Xe_exp_cb (w, client, call)
  2063. XWidget w;
  2064. XXtPointer client;
  2065. XXtPointer call;
  2066. X{
  2067. X    XmDrawingAreaCallbackStruct *c = (XmDrawingAreaCallbackStruct *)call;
  2068. X
  2069. X    /* filter out a few oddball cases */
  2070. X    switch (c->reason) {
  2071. X    case XmCR_EXPOSE: {
  2072. X        /* turn off gravity so we get expose events for either shrink or
  2073. X         * expand.
  2074. X         */
  2075. X        static before;
  2076. X        XExposeEvent *e = &c->event->xexpose;
  2077. X
  2078. X        if (!before) {
  2079. X        XSetWindowAttributes swa;
  2080. X        swa.bit_gravity = ForgetGravity;
  2081. X        XChangeWindowAttributes (e->display, e->window, 
  2082. X                                CWBitGravity, &swa);
  2083. X        before = 1;
  2084. X        }
  2085. X        /* wait for the last in the series */
  2086. X        if (e->count != 0)
  2087. X        return;
  2088. X        break;
  2089. X        }
  2090. X    default:
  2091. X        printf ("Unexpected eform_w event. type=%d\n", c->reason);
  2092. X        exit(1);
  2093. X    }
  2094. X
  2095. X    e_update (mm_get_now(), 1);
  2096. X}
  2097. X
  2098. X/* go through all the buttons and set whether they
  2099. X * should appear to look like buttons or just flat labels.
  2100. X */
  2101. Xstatic void
  2102. Xe_set_buttons (whether)
  2103. Xint whether;    /* whether setting up for plotting or for not plotting */
  2104. X{
  2105. X    static Arg look_like_button[] = {
  2106. X        {XmNtopShadowColor, (XtArgVal) 0},
  2107. X        {XmNbottomShadowColor, (XtArgVal) 0},
  2108. X        {XmNfillOnArm, (XtArgVal) True},
  2109. X    };
  2110. X    static Arg look_like_label[] = {
  2111. X        {XmNtopShadowColor, (XtArgVal) 0},
  2112. X        {XmNbottomShadowColor, (XtArgVal) 0},
  2113. X        {XmNfillOnArm, (XtArgVal) False},
  2114. X    };
  2115. X    static int called;
  2116. X    Arg *ap;
  2117. X    int na;
  2118. X
  2119. X    if (!called) {
  2120. X        /* get baseline label and shadow appearances.
  2121. X         */
  2122. X        Pixel topshad, botshad, bgcol;
  2123. X        Arg args[20];
  2124. X        int n;
  2125. X
  2126. X        n = 0;
  2127. X        XtSetArg (args[n], XmNtopShadowColor, &topshad); n++;
  2128. X        XtSetArg (args[n], XmNbottomShadowColor, &botshad); n++;
  2129. X        XtSetArg (args[n], XmNbackground, &bgcol); n++;
  2130. X        XtGetValues (e_lat_w, args, n);
  2131. X
  2132. X        look_like_button[0].value = topshad;
  2133. X        look_like_button[1].value = botshad;
  2134. X        look_like_label[0].value = bgcol;
  2135. X        look_like_label[1].value = bgcol;
  2136. X
  2137. X        called = 1;
  2138. X    }
  2139. X
  2140. X    if (whether) {
  2141. X        ap = look_like_button;
  2142. X        na = XtNumber(look_like_button);
  2143. X    } else {
  2144. X        ap = look_like_label;
  2145. X        na = XtNumber(look_like_label);
  2146. X    }
  2147. X
  2148. X    XtSetValues (e_lat_w, ap, na);
  2149. X    XtSetValues (e_long_w, ap, na);
  2150. X}
  2151. X
  2152. X/* return the long and lat of the subsolar point (where the sun is directly
  2153. X * overhead) at np.
  2154. X * both are in rads, lat is +N, long is +E.
  2155. X */
  2156. Xstatic void
  2157. Xe_subsolar(np, latp, longp)
  2158. XNow *np;
  2159. Xdouble *latp, *longp;
  2160. X{
  2161. X    Obj o;
  2162. X    double gst;
  2163. X
  2164. X    o.type = PLANET;
  2165. X    o.pl.code = SUN;
  2166. X
  2167. X    if (obj_cir (np, &o) < 0) {
  2168. X        printf ("e_subsolar(): can't get sun loc\n");
  2169. X        exit (1);
  2170. X    }
  2171. X    if (epoch != EOD) {
  2172. X        double tra = o.s_ra, tdec = o.s_dec;
  2173. X        precess (epoch, mjd, &tra, &tdec);
  2174. X        o.s_ra = tra;
  2175. X        o.s_dec = tdec;
  2176. X    }
  2177. X
  2178. X    *latp = o.s_dec;
  2179. X
  2180. X    utc_gst (mjd_day(mjd), mjd_hr(mjd), &gst);
  2181. X    *longp =  o.s_ra - hrrad(gst);    /* remember: we want +E */
  2182. X}
  2183. X
  2184. X/* draw map centered at slat/slong.
  2185. X * each in rads, slat is +N, slong is +E.
  2186. X */
  2187. Xstatic void
  2188. Xe_map (np, slat, slong)
  2189. XNow *np;
  2190. Xdouble slat, slong;
  2191. X{
  2192. X#define    CRAD        20        /* cross radius, pixels */
  2193. X#define    COAST_LW    2        /* line_width for drawing coast lines */
  2194. X#define    CROSS_LW    0        /* line_width for drawing the cross */
  2195. X#define    LINE_ST        LineSolid
  2196. X#define    CAP_ST        CapRound
  2197. X#define    JOIN_ST        JoinRound
  2198. X    static unsigned long last_w, last_h;
  2199. X    static Pixmap e_pm;
  2200. X    static GC e_gc;
  2201. X    static Pixel e_fg, e_bg;
  2202. X    Display *dsp = XtDisplay(e_da_w);
  2203. X    Window win = XtWindow(e_da_w);
  2204. X    int x, y;
  2205. X    unsigned w, h, b, d;
  2206. X    Window root;
  2207. X    int wb, hb, r;
  2208. X    MRegion *rp;
  2209. X    MCoord *cp;
  2210. X
  2211. X    /* make the GC if this is our first time */
  2212. X    if (!e_gc) {
  2213. X        XGCValues gcv;
  2214. X        unsigned long gcm;
  2215. X
  2216. X        gcm = 0;
  2217. X        e_gc = XCreateGC (dsp, win, gcm, &gcv);
  2218. X
  2219. X        get_something (e_da_w, XmNforeground, (char *)&e_fg);
  2220. X        get_something (e_da_w, XmNbackground, (char *)&e_bg);
  2221. X    }
  2222. X
  2223. X    /* set up width and height borders and the radius so the
  2224. X     * planetary sphere is a circle centered within the window.
  2225. X     */
  2226. X    XGetGeometry (dsp, win, &root, &x, &y, &w, &h, &b, &d);
  2227. X    if (w > h) {
  2228. X        wb = (w - h)/2;
  2229. X        hb = 0;
  2230. X        r = h/2;
  2231. X    } else {
  2232. X        wb = 0;
  2233. X        hb = (h - w)/2;
  2234. X        r = w/2;
  2235. X    }
  2236. X
  2237. X    /* make the pixmap if this is our first time or the size has changed */
  2238. X    if (!e_pm || w != last_w || h != last_h) {
  2239. X        last_w = w;
  2240. X        last_h = h;
  2241. X        if (e_pm)
  2242. X        XFreePixmap (dsp, e_pm);
  2243. X        e_pm = XCreatePixmap (dsp, win, w, h, d);
  2244. X    }
  2245. X
  2246. X    /* clear the scene, draw filled circle in foreground then fill in
  2247. X     * each region in background.
  2248. X     */
  2249. X    XSetLineAttributes (dsp, e_gc, COAST_LW, LINE_ST, CAP_ST, JOIN_ST);
  2250. X    XSetForeground (dsp, e_gc, e_bg);
  2251. X    XFillRectangle (dsp, e_pm, e_gc, 0, 0, w, h);
  2252. X    XSetForeground (dsp, e_gc, e_fg);
  2253. X    XFillArc (dsp, e_pm, e_gc, wb, hb, 2*r, 2*r, 0, 360*64);
  2254. X    XSetForeground (dsp, e_gc, e_bg);
  2255. X    for (rp = ereg; rp < ereg + nereg; rp++) {
  2256. X        XPoint xp[1024];
  2257. X        int nxp = 0;
  2258. X        MCoord *lastcp = rp->mcp + rp->nmcp - 1;
  2259. X        for (cp = rp->mcp; cp <= lastcp; cp++) {
  2260. X        /* rotate to (lat,long)=(0,0) then project onto x/y plane */
  2261. X        double longp = degrad(cp->lg) - slong;
  2262. X        double z = r*cos(longp);
  2263. X        if (z > 0 && nxp < XtNumber(xp)) {
  2264. X            double latp = degrad(cp->lt) - slat;
  2265. X            double lx = r*sin(longp)*cos(latp);
  2266. X            double ly = -r*sin(latp);
  2267. X            xp[nxp].x = (int)floor(lx+0.5) + wb + r;
  2268. X            xp[nxp].y = (int)floor(ly+0.5) + hb + r;
  2269. X            nxp++;
  2270. X        }
  2271. X        if (z < 0 || cp == lastcp) {
  2272. X            if (nxp > 1)
  2273. X            XDrawLines (dsp, e_pm, e_gc, xp, nxp, CoordModeOrigin);
  2274. X            nxp = 0;
  2275. X        }
  2276. X        }
  2277. X    }
  2278. X
  2279. X    /* draw a cross-hair in the center to mark the subsolar point */
  2280. X    XSetLineAttributes (dsp, e_gc, CROSS_LW, LINE_ST, CAP_ST, JOIN_ST);
  2281. X    XDrawLine (dsp, e_pm, e_gc, wb+r-CRAD, hb+r-CRAD, wb+r+CRAD, hb+r+CRAD);
  2282. X    XDrawLine (dsp, e_pm, e_gc, wb+r-CRAD, hb+r+CRAD, wb+r+CRAD, hb+r-CRAD);
  2283. X
  2284. X    XSetFunction (dsp, e_gc, GXcopy);
  2285. X    XCopyArea (dsp, e_pm, win, e_gc, 0, 0, w, h, 0, 0);
  2286. X
  2287. X    timestamp (np, e_dt_w);
  2288. X}
  2289. END_OF_FILE
  2290.   if test 16271 -ne `wc -c <'earthmenu.c'`; then
  2291.     echo shar: \"'earthmenu.c'\" unpacked with wrong size!
  2292.   fi
  2293.   # end of 'earthmenu.c'
  2294. fi
  2295. if test -f 'srchmenu.c' -a "${1}" != "-c" ; then 
  2296.   echo shar: Will not clobber existing file \"'srchmenu.c'\"
  2297. else
  2298.   echo shar: Extracting \"'srchmenu.c'\" \(27491 characters\)
  2299.   sed "s/^X//" >'srchmenu.c' <<'END_OF_FILE'
  2300. X/* this file contains functions to support iterative xephem searches.
  2301. X * we support several kinds of searching and solving algorithms.
  2302. X * the expressions being evaluated are compiled and executed from compiler.c.
  2303. X */
  2304. X
  2305. X#include <stdio.h>
  2306. X#include <ctype.h>
  2307. X#include <math.h>
  2308. X#if defined(__STDC__)
  2309. X#include <stdlib.h>
  2310. X#endif
  2311. X#include <X11/Xlib.h>
  2312. X#include <Xm/Xm.h>
  2313. X#include <Xm/Form.h>
  2314. X#include <Xm/Frame.h>
  2315. X#include <Xm/Label.h>
  2316. X#include <Xm/PushB.h>
  2317. X#include <Xm/RowColumn.h>
  2318. X#include <Xm/Separator.h>
  2319. X#include <Xm/SelectioB.h>
  2320. X#include <Xm/ToggleB.h>
  2321. X#include <Xm/Text.h>
  2322. X#include "astro.h"
  2323. X#include "circum.h"
  2324. X
  2325. X#if defined(__STDC__) || defined(__cplusplus)
  2326. X#define P_(s) s
  2327. X#else
  2328. X#define P_(s) ()
  2329. X#endif
  2330. X
  2331. Xextern Now *mm_get_now P_((void));
  2332. Xextern int any_ison P_((void));
  2333. Xextern int compile_expr P_((char *ex, char *errbuf));
  2334. Xextern int execute_expr P_((double *vp, char *errbuf));
  2335. Xextern int prog_isgood P_((void));
  2336. Xextern void all_selection_mode P_((int whether));
  2337. Xextern void compiler_log P_((char *name, double value));
  2338. Xextern void f_dec_sexsign P_((double x, int *h, int *m, int *s));
  2339. Xextern void f_double P_((Widget w, char *fmt, double f));
  2340. Xextern void f_sscansex P_((char *bp, int *d, int *m, int *s));
  2341. Xextern void f_time P_((Widget w, double t));
  2342. Xextern void get_xmstring P_((Widget w, char *resource, char **txtp));
  2343. Xextern void hlp_dialog P_((char *tag, char *deflt[], int ndeflt));
  2344. Xextern void lst_selection P_((char *name));
  2345. Xextern void plt_selection P_((char *name));
  2346. Xextern void prompt_map_cb P_((Widget w, XtPointer client, XtPointer call));
  2347. Xextern void redraw_screen P_((int how_much));
  2348. Xextern void set_something P_((Widget w, char *resource, char *value));
  2349. Xextern void set_xmstring P_((Widget w, char *resource, char *txt));
  2350. Xextern void sex_dec P_((int hd, int m, int s, double *d));
  2351. Xextern void xe_msg P_((char *msg, int app_modal));
  2352. X
  2353. Xvoid srch_manage P_((void));
  2354. Xvoid srch_selection_mode P_((int whether));
  2355. Xvoid srch_selection P_((char *name));
  2356. Xint srch_eval P_((double Mjd, double *tmincp));
  2357. Xint srch_ison P_((void));
  2358. Xvoid srch_log P_((char *name, double value));
  2359. Xvoid srch_cursor P_((Cursor c));
  2360. Xstatic void srch_create_form P_((void));
  2361. Xstatic srch_isup P_((void));
  2362. Xstatic srching_now P_((void));
  2363. Xstatic void srch_set_buttons P_((int whether));
  2364. Xstatic void srch_use_cb P_((Widget w, XtPointer client, XtPointer call));
  2365. Xstatic void srch_funcactivate_cb P_((Widget w, XtPointer client, XtPointer call));
  2366. Xstatic void srch_compile_cb P_((Widget w, XtPointer client, XtPointer call));
  2367. Xstatic void srch_help_cb P_((Widget w, XtPointer client, XtPointer call));
  2368. Xstatic void srch_fields_cb P_((Widget w, XtPointer client, XtPointer call));
  2369. Xstatic void srch_close_cb P_((Widget w, XtPointer client, XtPointer call));
  2370. Xstatic void srch_acc_ok_cb P_((Widget w, XtPointer client, XtPointer call));
  2371. Xstatic void srch_acc_cb P_((Widget wid, XtPointer client, XtPointer call));
  2372. Xstatic void srch_goal_cb P_((Widget w, XtPointer client, XtPointer call));
  2373. Xstatic void srch_on_off_cb P_((Widget w, XtPointer client, XtPointer call));
  2374. Xstatic srch_minmax P_((double Mjd, double v, double *tmincp));
  2375. Xstatic srch_solve0 P_((double Mjd, double v, double *tmincp));
  2376. Xstatic srch_binary P_((double Mjd, double v, double *tmincp));
  2377. X
  2378. X#undef P_
  2379. X
  2380. Xextern Widget toplevel_w;
  2381. X#define    XtD    XtDisplay(toplevel_w)
  2382. X
  2383. X/* the widgets we need direct access to */
  2384. Xstatic Widget srchform_w;
  2385. Xstatic Widget help_w;
  2386. Xstatic Widget acc_w;
  2387. Xstatic Widget field_w;
  2388. Xstatic Widget func_w;    /* contains the search function [to be] compiled */
  2389. Xstatic Widget err_w;
  2390. Xstatic Widget compile_w;
  2391. Xstatic Widget valu_w;    /* used to display most recent calulated value */
  2392. Xstatic Widget use_w;    /* use to select srch value for use in plotting */
  2393. Xstatic Widget on_w;    /* whether searching is active comes directly from this
  2394. X             * widget's XmToggleButtonGetState()
  2395. X             */
  2396. X
  2397. X/* name is it appears when valu_w is selected for plotting or lising */
  2398. Xstatic char srchvname[] = "SrchValue";
  2399. X
  2400. Xstatic int (*srch_f)();        /* 0 or pointer to one of the search functions*/
  2401. Xstatic int srch_tmscalled;    /* number of iterations so far */
  2402. Xstatic double tmlimit = 1./60.;    /* search accuracy, in hrs; def is one minute */
  2403. X
  2404. Xstatic int srch_selecting;    /* whether our value is currently selectable */
  2405. Xstatic int srch_self_selection_mode;    /* flag to prevent self-selection */
  2406. X
  2407. X/* called when the search menu is activated via the main menu pulldown.
  2408. X * if never called before, create and manage all the widgets as a child of a
  2409. X * form. otherwise, just toggle whether the form is managed.
  2410. X */
  2411. Xvoid
  2412. Xsrch_manage ()
  2413. X{
  2414. X    if (!srchform_w)
  2415. X        srch_create_form();
  2416. X    
  2417. X    if (XtIsManaged(srchform_w))
  2418. X        XtUnmanageChild (srchform_w);
  2419. X    else {
  2420. X        XtManageChild (srchform_w);
  2421. X        srch_set_buttons(srch_selecting);
  2422. X    }
  2423. X}
  2424. X
  2425. X/* called by other menus as they want to hear from our buttons or not.
  2426. X * the "on"s and "off"s stack - only really redo the buttons if it's the
  2427. X * first on or the last off.
  2428. X * N.B. we cooperate with a flag from the Enable pushbutton to prevent
  2429. X *   being able use the search function result as a term in the search funtion.
  2430. X */
  2431. Xvoid
  2432. Xsrch_selection_mode (whether)
  2433. Xint whether;    /* whether setting up for plotting or for not plotting */
  2434. X{
  2435. X    if (srch_self_selection_mode)
  2436. X        return;
  2437. X
  2438. X    srch_selecting += whether ? 1 : -1;
  2439. X
  2440. X    if (srchform_w && XtIsManaged(srchform_w))
  2441. X        if (whether && srch_selecting == 1     /* first one to want on */
  2442. X        || !whether && srch_selecting == 0 /* last one to want off */)
  2443. X        srch_set_buttons (whether);
  2444. X}
  2445. X
  2446. X/* called when other modules, such as data menu, have a button pushed
  2447. X * and we have asked (by enabling field buttons) that they inform us that
  2448. X * that button is to be included in the search function.
  2449. X * other modules that use buttons, such as plotting and listing, might ask
  2450. X * too so it might not really be us that wants to use it.
  2451. X */
  2452. Xvoid
  2453. Xsrch_selection (name)
  2454. Xchar *name;
  2455. X{
  2456. X    int ins;
  2457. X    char *qname;
  2458. X
  2459. X    if (!srchform_w
  2460. X        || !XtIsManaged(srchform_w)
  2461. X        || !XmToggleButtonGetState(field_w))
  2462. X        return;
  2463. X
  2464. X    ins = XmTextGetInsertionPosition (func_w);
  2465. X    qname = XtMalloc (strlen(name) + 3);    /* two '"' and \0 */
  2466. X    (void) sprintf (qname, "\"%s\"", name);
  2467. X    XmTextReplace (func_w, /* from */ ins, /* to */ ins, qname);
  2468. X    XtFree (qname);
  2469. X
  2470. X    /* move the focus right back to the search menu so the insertion point
  2471. X     * remains visible.
  2472. X     */
  2473. X    XSetInputFocus (XtDisplay(srchform_w), XtWindow(srchform_w),
  2474. X                        RevertToParent, CurrentTime);
  2475. X}
  2476. X
  2477. X/* if searching is in effect call the search type function.
  2478. X * it might modify *tmincp according to where it next wants to eval.
  2479. X * (remember tminc is in hours, not days).
  2480. X * if searching ends for any reason it is also turned off.
  2481. X * if we are not searching but are plotting or listing we still execute the
  2482. X *   search function (if it is ok) and flog and display it.
  2483. X * return 0 if caller can continue or -1 if it is time to stop.
  2484. X */
  2485. Xsrch_eval(Mjd, tmincp)
  2486. Xdouble Mjd;
  2487. Xdouble *tmincp;
  2488. X{
  2489. X    int s;
  2490. X
  2491. X    if (prog_isgood() && any_ison()) {
  2492. X        char errbuf[128];
  2493. X        double v;
  2494. X        s = execute_expr (&v, errbuf);
  2495. X        if (s == 0) {
  2496. X        f_double (valu_w, "%g", v);
  2497. X        if (srching_now()) {
  2498. X            s = (*srch_f)(Mjd, v, tmincp);
  2499. X            srch_tmscalled++;
  2500. X        }
  2501. X        } else {
  2502. X        char srchmsg[256];
  2503. X        (void) sprintf (srchmsg, "Search evaluation error: %.200s",
  2504. X                                    errbuf);
  2505. X        xe_msg (srchmsg, 0);
  2506. X        }
  2507. X    } else
  2508. X        s = 0;
  2509. X
  2510. X    if (s < 0)
  2511. X        XmToggleButtonSetState(on_w, False, /*invoke cb*/True);
  2512. X
  2513. X    return (s);
  2514. X}
  2515. X
  2516. X/* called by other systems to decide whether it is worth computing and
  2517. X *   logging values to the search system.
  2518. X * we say True whenever there is a validly compiled function and either we are
  2519. X *   searching (obviously) or the srch control menu is up.
  2520. X */
  2521. Xsrch_ison()
  2522. X{
  2523. X    return (prog_isgood() && (srching_now() || srch_isup()));
  2524. X}
  2525. X
  2526. X/* called as each different field is written -- just tell the compiler
  2527. X * if we are interested in it.
  2528. X * we have to check if *anything* is on because we might be plotting/listing
  2529. X *   the srch function itself.
  2530. X */
  2531. Xvoid
  2532. Xsrch_log (name, value)
  2533. Xchar *name;
  2534. Xdouble value;
  2535. X{
  2536. X    if (any_ison())
  2537. X        compiler_log (name, value);
  2538. X}
  2539. X
  2540. X/* called to put up or remove the watch cursor.  */
  2541. Xvoid
  2542. Xsrch_cursor (c)
  2543. XCursor c;
  2544. X{
  2545. X    Window win;
  2546. X
  2547. X    if (srchform_w && (win = XtWindow(srchform_w))) {
  2548. X        Display *dsp = XtDisplay(srchform_w);
  2549. X        if (c)
  2550. X        XDefineCursor (dsp, win, c);
  2551. X        else
  2552. X        XUndefineCursor (dsp, win);
  2553. X    }
  2554. X}
  2555. X
  2556. Xstatic void
  2557. Xsrch_create_form()
  2558. X{
  2559. X    static struct {
  2560. X        char *title;
  2561. X        XtPointer cb_data;
  2562. X    } rbtb[] = {
  2563. X        {"Find Extreme", (XtPointer)srch_minmax},
  2564. X        {"Find 0", (XtPointer)srch_solve0},
  2565. X        {"Binary", (XtPointer)srch_binary},
  2566. X    };
  2567. X    XmString str;
  2568. X    Widget w, rc_w, f_w, rb_w;
  2569. X    Arg args[20];
  2570. X    int i, n;
  2571. X
  2572. X    /* create form dialog */
  2573. X    n = 0;
  2574. X    XtSetArg (args[n], XmNautoUnmanage, False); n++;
  2575. X    XtSetArg (args[n], XmNdefaultPosition, False); n++;
  2576. X    srchform_w = XmCreateFormDialog (toplevel_w, "Srch", args, n);
  2577. X
  2578. X    /* set some stuff in the parent DialogShell.
  2579. X     * setting XmNdialogTitle in the Form didn't work..
  2580. X     */
  2581. X    n = 0;
  2582. X    XtSetArg (args[n], XmNtitle, "xephem Search Control"); n++;
  2583. X    XtSetValues (XtParent(srchform_w), args, n);
  2584. X
  2585. X    /* create a RowColumn to hold stuff */
  2586. X    n = 0;
  2587. X    XtSetArg (args[n], XmNtopAttachment, XmATTACH_FORM); n++;
  2588. X    XtSetArg (args[n], XmNbottomAttachment, XmATTACH_FORM); n++;
  2589. X    XtSetArg (args[n], XmNleftAttachment, XmATTACH_FORM); n++;
  2590. X    XtSetArg (args[n], XmNrightAttachment, XmATTACH_FORM); n++;
  2591. X    XtSetArg (args[n], XmNisAligned, False); n++;
  2592. X    XtSetArg (args[n], XmNadjustMargin, False); n++;
  2593. X    rc_w = XmCreateRowColumn (srchform_w, "SrchRC", args, n);
  2594. X    XtManageChild (rc_w);
  2595. X
  2596. X    /* searching on/off toggle button */
  2597. X
  2598. X    n = 0;
  2599. X    on_w = XmCreateToggleButton (rc_w, "Searching is Active", args, n);
  2600. X    XtAddCallback (on_w, XmNvalueChangedCallback, srch_on_off_cb, 0);
  2601. X    XtManageChild (on_w);
  2602. X
  2603. X    /* create a separator */
  2604. X
  2605. X    n = 0;
  2606. X    w = XmCreateSeparator (rc_w, "Sep1", args, n);
  2607. X    XtManageChild (w);
  2608. X
  2609. X    /* compiler area title */
  2610. X
  2611. X    str = XmStringCreate ("Search Function:",
  2612. X                            XmSTRING_DEFAULT_CHARSET);
  2613. X    n = 0;
  2614. X    XtSetArg (args[n], XmNalignment, XmALIGNMENT_BEGINNING); n++;
  2615. X    XtSetArg (args[n], XmNlabelString, str); n++;
  2616. X    w = XmCreateLabel (rc_w, "FuncL", args, n);
  2617. X    XtManageChild (w);
  2618. X
  2619. X    /* function text.
  2620. X     * arrange for Return to activate the Compile button.
  2621. X     */
  2622. X
  2623. X    n = 0;
  2624. X    func_w = XmCreateText (rc_w, "SrchFunction", args, n);
  2625. X    XtAddCallback (func_w, XmNactivateCallback, srch_funcactivate_cb, NULL);
  2626. X    XtManageChild (func_w);
  2627. X
  2628. X    /* compiler message label */
  2629. X
  2630. X    n = 0;
  2631. X    XtSetArg (args[n], XmNalignment, XmALIGNMENT_BEGINNING); n++;
  2632. X    err_w = XmCreateLabel (rc_w, "SrchErrsL", args, n);
  2633. X    XtManageChild (err_w);
  2634. X    set_xmstring (err_w, XmNlabelString, " ");
  2635. X
  2636. X    /* use-fields button */
  2637. X
  2638. X    str = XmStringCreate("Enable field buttons", XmSTRING_DEFAULT_CHARSET);
  2639. X    n = 0;
  2640. X    XtSetArg (args[n], XmNlabelString, str); n++;
  2641. X    field_w = XmCreateToggleButton (rc_w, "SrchFEnable", args, n);
  2642. X    XtAddCallback (field_w, XmNvalueChangedCallback, srch_fields_cb, 0);
  2643. X    XtManageChild (field_w);
  2644. X    XmStringFree(str);
  2645. X
  2646. X    /* COMPILE push button */
  2647. X
  2648. X    n = 0;
  2649. X    XtSetArg (args[n], XmNshowAsDefault, True); n++;
  2650. X    compile_w = XmCreatePushButton (rc_w, "Compile", args, n);
  2651. X    XtAddCallback (compile_w, XmNactivateCallback, srch_compile_cb, 0);
  2652. X    XtManageChild (compile_w);
  2653. X    set_something (srchform_w, XmNdefaultButton, (char *)w);
  2654. X
  2655. X    /* create a separator */
  2656. X
  2657. X    n = 0;
  2658. X    w = XmCreateSeparator (rc_w, "Sep2", args, n);
  2659. X    XtManageChild (w);
  2660. X
  2661. X    /* create goal radio box and its toggle buttons */
  2662. X
  2663. X    str = XmStringCreate ("Search goal:", XmSTRING_DEFAULT_CHARSET);
  2664. X    n = 0;
  2665. X    XtSetArg (args[n], XmNalignment, XmALIGNMENT_BEGINNING); n++;
  2666. X    XtSetArg (args[n], XmNlabelString, str); n++;
  2667. X    w = XmCreateLabel (rc_w, "SrchRBL", args, n);
  2668. X    XtManageChild(w);
  2669. X    XmStringFree(str);
  2670. X
  2671. X    n = 0;
  2672. X    XtSetArg (args[n], XmNorientation, XmVERTICAL); n++;
  2673. X    rb_w = XmCreateRadioBox (rc_w, "SrchGoalRadioBox", args, n);
  2674. X    XtManageChild (rb_w);
  2675. X
  2676. X        for (i = 0; i < XtNumber(rbtb); i++) {
  2677. X        n = 0;
  2678. X        str = XmStringCreate(rbtb[i].title, XmSTRING_DEFAULT_CHARSET);
  2679. X        XtSetArg (args[n], XmNlabelString, str); n++;
  2680. X        w = XmCreateToggleButton (rb_w, "SrchRBTB", args, n);
  2681. X        XtAddCallback (w, XmNvalueChangedCallback, srch_goal_cb,
  2682. X                            (XtPointer)rbtb[i].cb_data);
  2683. X        XtManageChild (w);
  2684. X        XmStringFree(str);
  2685. X        }
  2686. X
  2687. X    /* create a separator */
  2688. X
  2689. X    n = 0;
  2690. X    w = XmCreateSeparator (rc_w, "Sep3", args, n);
  2691. X    XtManageChild (w);
  2692. X
  2693. X    /* Accuracy label and its push button in a form */
  2694. X
  2695. X    n = 0;
  2696. X    f_w = XmCreateForm (rc_w, "SrchAF", args, n);
  2697. X    XtManageChild (f_w);
  2698. X
  2699. X        n = 0;
  2700. X        XtSetArg (args[n], XmNtopAttachment, XmATTACH_FORM); n++;
  2701. X        XtSetArg (args[n], XmNbottomAttachment, XmATTACH_FORM); n++;
  2702. X        XtSetArg (args[n], XmNrightAttachment, XmATTACH_FORM); n++;
  2703. X        acc_w = XmCreatePushButton (f_w, "SrchAcc", args, n);
  2704. X        XtAddCallback (acc_w, XmNactivateCallback, srch_acc_cb, 0);
  2705. X        f_time (acc_w, tmlimit);
  2706. X        XtManageChild (acc_w);
  2707. X
  2708. X        str = XmStringCreate("Desired accuracy:", XmSTRING_DEFAULT_CHARSET);
  2709. X        n = 0;
  2710. X        XtSetArg (args[n], XmNtopAttachment, XmATTACH_FORM); n++;
  2711. X        XtSetArg (args[n], XmNbottomAttachment, XmATTACH_FORM); n++;
  2712. X        XtSetArg (args[n], XmNleftAttachment, XmATTACH_FORM); n++;
  2713. X        XtSetArg (args[n], XmNrightAttachment, XmATTACH_WIDGET); n++;
  2714. X        XtSetArg (args[n], XmNrightWidget, acc_w); n++;
  2715. X        XtSetArg (args[n], XmNalignment, XmALIGNMENT_BEGINNING); n++;
  2716. X        XtSetArg (args[n], XmNlabelString, str); n++;
  2717. X        w = XmCreateLabel (f_w, "SrchAccL", args, n);
  2718. X        XmStringFree (str);
  2719. X        XtManageChild (w);
  2720. X
  2721. X    /* create a separator */
  2722. X
  2723. X    n = 0;
  2724. X    w = XmCreateSeparator (rc_w, "Sep4", args, n);
  2725. X    XtManageChild (w);
  2726. X
  2727. X    /* current search value in a form */
  2728. X
  2729. X    n = 0;
  2730. X    f_w = XmCreateForm (rc_w, "SrchVF", args, n);
  2731. X    XtManageChild (f_w);
  2732. X
  2733. X        n = 0;
  2734. X        XtSetArg (args[n], XmNtopAttachment, XmATTACH_FORM); n++;
  2735. X        XtSetArg (args[n], XmNbottomAttachment, XmATTACH_FORM); n++;
  2736. X        XtSetArg (args[n], XmNrightAttachment, XmATTACH_FORM); n++;
  2737. X        valu_w = XmCreateLabel (f_w, "SrchValu", args, n);
  2738. X        XtManageChild (valu_w);
  2739. X        set_xmstring (valu_w, XmNlabelString, "");
  2740. X
  2741. X        str = XmStringCreate ("Current value: ", XmSTRING_DEFAULT_CHARSET);
  2742. X        n = 0;
  2743. X        XtSetArg (args[n], XmNtopAttachment, XmATTACH_FORM); n++;
  2744. X        XtSetArg (args[n], XmNbottomAttachment, XmATTACH_FORM); n++;
  2745. X        XtSetArg (args[n], XmNleftAttachment, XmATTACH_FORM); n++;
  2746. X        XtSetArg (args[n], XmNrightAttachment, XmATTACH_WIDGET); n++;
  2747. X        XtSetArg (args[n], XmNrightWidget, valu_w); n++;
  2748. X        XtSetArg (args[n], XmNalignment, XmALIGNMENT_BEGINNING); n++;
  2749. X        XtSetArg (args[n], XmNlabelString, str); n++;
  2750. X        w = XmCreateLabel (f_w, "SrchValuL", args, n);
  2751. X        XtManageChild (w);
  2752. X        XmStringFree (str);
  2753. X
  2754. X        /* add the name in the userData field in case it's plotted or
  2755. X         * listed
  2756. X         */
  2757. X        set_something (valu_w, XmNuserData, srchvname);
  2758. X
  2759. X    /* button to select using for plotting. 
  2760. X     * ONLY MANAGED WHEN WE ARE TOLD TO SELECT FOR PLOTTING.
  2761. X     */
  2762. X
  2763. X    n = 0;
  2764. X    use_w = XmCreatePushButton (rc_w, "SrchUse", args, n);
  2765. X    XtAddCallback (use_w, XmNactivateCallback, srch_use_cb, 0);
  2766. X    set_xmstring (use_w, XmNlabelString, "Use for plotting");
  2767. X
  2768. X    /* create a separator */
  2769. X
  2770. X    n = 0;
  2771. X    w = XmCreateSeparator (rc_w, "Sep4", args, n);
  2772. X    XtManageChild (w);
  2773. X
  2774. X    /* form to hold bottom control buttons */
  2775. X
  2776. X    n = 0;
  2777. X    XtSetArg (args[n], XmNfractionBase, 7); n++;
  2778. X    f_w = XmCreateForm (rc_w, "SrchCF", args, n);
  2779. X    XtManageChild (f_w);
  2780. X
  2781. X        n = 0;
  2782. X        XtSetArg (args[n], XmNtopAttachment, XmATTACH_FORM); n++;
  2783. X        XtSetArg (args[n], XmNbottomAttachment, XmATTACH_FORM); n++;
  2784. X        XtSetArg (args[n], XmNleftAttachment, XmATTACH_POSITION); n++;
  2785. X        XtSetArg (args[n], XmNleftPosition, 1); n++;
  2786. X        XtSetArg (args[n], XmNrightAttachment, XmATTACH_POSITION); n++;
  2787. X        XtSetArg (args[n], XmNrightPosition, 3); n++;
  2788. X        w = XmCreatePushButton(f_w, "Close", args,n);
  2789. X        XtManageChild (w);
  2790. X        XtAddCallback(w, XmNactivateCallback, srch_close_cb, 0);
  2791. X
  2792. X        n = 0;
  2793. X        XtSetArg (args[n], XmNtopAttachment, XmATTACH_FORM); n++;
  2794. X        XtSetArg (args[n], XmNbottomAttachment, XmATTACH_FORM); n++;
  2795. X        XtSetArg (args[n], XmNleftAttachment, XmATTACH_POSITION); n++;
  2796. X        XtSetArg (args[n], XmNleftPosition, 4); n++;
  2797. X        XtSetArg (args[n], XmNrightAttachment, XmATTACH_POSITION); n++;
  2798. X        XtSetArg (args[n], XmNrightPosition, 6); n++;
  2799. X        help_w = XmCreatePushButton(f_w, "Help", args, n);
  2800. X        XtManageChild (help_w);
  2801. X        XtAddCallback(help_w, XmNactivateCallback, srch_help_cb, 0);
  2802. X}
  2803. X
  2804. X/* return True whenever the srch control menu is up */
  2805. Xstatic
  2806. Xsrch_isup()
  2807. X{
  2808. X    return (srchform_w && XtIsManaged(srchform_w));
  2809. X}
  2810. X
  2811. X/* return True whenever we are actually in the midst of controlling a search.
  2812. X */
  2813. Xstatic
  2814. Xsrching_now()
  2815. X{
  2816. X    return (on_w && XmToggleButtonGetState(on_w));
  2817. X}
  2818. X
  2819. X/* go through all the buttons pickable for plotting and set whether they
  2820. X * should appear to look like buttons.
  2821. X */
  2822. Xstatic void
  2823. Xsrch_set_buttons (whether)
  2824. Xint whether;    /* whether setting up for plotting or for not plotting */
  2825. X{
  2826. X    if (whether)
  2827. X        XtManageChild (use_w);
  2828. X    else
  2829. X        XtUnmanageChild (use_w);
  2830. X}
  2831. X
  2832. X/* callback from the "use" button.
  2833. X * if plotting or listing has put us in selecting mode, we look like a button
  2834. X * and we should inform them we have been picked.
  2835. X * otherwise, we do nothing (we didn't look like a button anyway).
  2836. X */
  2837. X/* ARGSUSED */
  2838. Xstatic void
  2839. Xsrch_use_cb (w, client, call)
  2840. XWidget w;
  2841. XXtPointer client;
  2842. XXtPointer call;
  2843. X{
  2844. X    static char msg[] =
  2845. X        "You must first successfully compile a search\nfunction before value may be selected.";
  2846. X
  2847. X    if (srch_selecting) {
  2848. X        if (prog_isgood()) {
  2849. X        plt_selection (srchvname);
  2850. X        lst_selection (srchvname);
  2851. X        } else
  2852. X        xe_msg (msg, 0);
  2853. X    }
  2854. X}
  2855. X
  2856. X/* callback when Return is typed in the function text widget.
  2857. X * we just stimulate the Compile button as per Heller, pg 219.
  2858. X */
  2859. X/* ARGSUSED */
  2860. Xstatic void
  2861. Xsrch_funcactivate_cb (w, client, call)
  2862. XWidget w;
  2863. XXtPointer client;
  2864. XXtPointer call;
  2865. X{
  2866. X    XmAnyCallbackStruct *cbs = (XmAnyCallbackStruct *) call;
  2867. X
  2868. X    XtCallActionProc (compile_w, "ArmAndActivate", cbs->event, NULL, 0);
  2869. X}
  2870. X
  2871. X/* callback from the compile button.
  2872. X */
  2873. X/* ARGSUSED */
  2874. Xstatic void
  2875. Xsrch_compile_cb (w, client, call)
  2876. XWidget w;
  2877. XXtPointer client;
  2878. XXtPointer call;
  2879. X{
  2880. X    char *newexp;
  2881. X    char errbuf[256];
  2882. X
  2883. X    newexp = XmTextGetString (func_w);
  2884. X    if (compile_expr (newexp, errbuf) <  0)
  2885. X        set_xmstring (err_w, XmNlabelString, errbuf);
  2886. X    else
  2887. X        set_xmstring (err_w, XmNlabelString, "<no compile errors>");
  2888. X
  2889. X    XtFree (newexp);
  2890. X
  2891. X    /* as a courtesy, turn off searching if it's currently active */
  2892. X    if (XmToggleButtonGetState(on_w))
  2893. X        XmToggleButtonSetState(on_w, False, True/*invoke cb*/);
  2894. X
  2895. X    /* compute the new function.
  2896. X     * must update everything else first because our function uses that
  2897. X     *   stuff in all likelihood.
  2898. X     */
  2899. X    if (prog_isgood()) {
  2900. X        Now *np = mm_get_now();
  2901. X        redraw_screen(1);
  2902. X        (void) srch_eval (mjd, (double *)NULL);
  2903. X    }
  2904. X}
  2905. X
  2906. X/* callback from the help button.
  2907. X */
  2908. X/* ARGSUSED */
  2909. Xstatic void
  2910. Xsrch_help_cb (w, client, call)
  2911. XWidget w;
  2912. XXtPointer client;
  2913. XXtPointer call;
  2914. X{
  2915. Xstatic char *help_msg[] = {
  2916. X"This menu controls the automatic searching facility. You define an arithmetic",
  2917. X"or boolean function, using most of the fields xephem displays, then xephem",
  2918. X"will automatically evaluate the function and adjust the time on each",
  2919. X"iteration to search for the goal.",
  2920. X"",
  2921. X"To perform a search:",
  2922. X"   enter a function,",
  2923. X"   compile it,",
  2924. X"   select a goal,",
  2925. X"   set the desired accuracy,",
  2926. X"   enable searching,",
  2927. X"   perform the search by stepping xephem."
  2928. X};
  2929. X
  2930. X    hlp_dialog ("Search", help_msg, sizeof(help_msg)/sizeof(help_msg[0]));
  2931. X}
  2932. X
  2933. X/* callback from the "field enable" push button.
  2934. X * inform the other menues whether we are setting up for them to tell us
  2935. X * what fields to plot.
  2936. X */
  2937. X/* ARGSUSED */
  2938. Xstatic void
  2939. Xsrch_fields_cb (w, client, call)
  2940. XWidget w;
  2941. XXtPointer client;
  2942. XXtPointer call;
  2943. X{
  2944. X    int whether = XmToggleButtonGetState(w);;
  2945. X
  2946. X    /* don't use our own result to srch with */
  2947. X    srch_self_selection_mode = 1;
  2948. X    all_selection_mode(whether);
  2949. X    srch_self_selection_mode = 0;
  2950. X}
  2951. X
  2952. X/* callback from the Close button.
  2953. X */
  2954. X/* ARGSUSED */
  2955. Xstatic void
  2956. Xsrch_close_cb (w, client, call)
  2957. XWidget w;
  2958. XXtPointer client;
  2959. XXtPointer call;
  2960. X{
  2961. X    XtUnmanageChild (srchform_w);
  2962. X}
  2963. X
  2964. X/* user typed OK to the accuracy prompt. get his new value and use it */
  2965. X/* ARGSUSED */
  2966. Xstatic void
  2967. Xsrch_acc_ok_cb (w, client, call)
  2968. XWidget w;
  2969. XXtPointer client;
  2970. XXtPointer call;
  2971. X{
  2972. X    int hrs, mins, secs;
  2973. X    char *text;
  2974. X    
  2975. X    f_dec_sexsign (tmlimit, &hrs, &mins, &secs);
  2976. X    get_xmstring(w, XmNtextString, &text);
  2977. X    f_sscansex (text, &hrs, &mins, &secs);
  2978. X    XtFree (text);
  2979. X    sex_dec (hrs, mins, secs, &tmlimit);
  2980. X    f_time (acc_w, tmlimit);
  2981. X    XtDestroyWidget (w);
  2982. X}
  2983. X
  2984. X/* callback from the accuracy-change-request pushbutton.
  2985. X * put up a prompt dialog to ask for a new value.
  2986. X */
  2987. X/* ARGSUSED */
  2988. Xstatic void
  2989. Xsrch_acc_cb (wid, client, call)
  2990. XWidget wid;
  2991. XXtPointer client;
  2992. XXtPointer call;
  2993. X{
  2994. X    Widget w, dw;
  2995. X    XmString str, title;
  2996. X    Arg args[20];
  2997. X    int n;
  2998. X    
  2999. X    str = XmStringCreate ("search accuracy (h:m:s):",
  3000. X                            XmSTRING_DEFAULT_CHARSET);
  3001. X    title = XmStringCreate ("xephem Search Accuracy",
  3002. X                            XmSTRING_DEFAULT_CHARSET);
  3003. X    n = 0;
  3004. X    XtSetArg(args[n], XmNdefaultPosition, False);  n++;
  3005. X    XtSetArg(args[n], XmNselectionLabelString, str);  n++;
  3006. X    XtSetArg(args[n], XmNdialogTitle, title);  n++;
  3007. X    dw = XmCreatePromptDialog(toplevel_w, "xephem Accuracy", args, n);
  3008. X    XtAddCallback (dw, XmNokCallback, srch_acc_ok_cb, NULL);
  3009. X    XtAddCallback (dw, XmNmapCallback, prompt_map_cb, NULL);
  3010. X    XmStringFree (str);
  3011. X    XmStringFree (title);
  3012. X
  3013. X    w = XmSelectionBoxGetChild (dw, XmDIALOG_HELP_BUTTON);
  3014. X    XtUnmanageChild (w);
  3015. X
  3016. X    XtManageChild (dw);
  3017. X
  3018. X#if XmVersion >= 1001
  3019. X    w = XmSelectionBoxGetChild (dw, XmDIALOG_TEXT);
  3020. X    XmProcessTraversal (w, XmTRAVERSE_CURRENT);
  3021. X    XmProcessTraversal (w, XmTRAVERSE_CURRENT); /* yes, twice!! */
  3022. X#endif
  3023. X}
  3024. X
  3025. X/* callback from the search goal selection radio buttons.
  3026. X * same callback used for all of them.
  3027. X * client is pointer to desired search function.
  3028. X */
  3029. X/* ARGSUSED */
  3030. Xstatic void
  3031. Xsrch_goal_cb(w, client, call)
  3032. XWidget w;
  3033. XXtPointer client;
  3034. XXtPointer call;
  3035. X{
  3036. X    int (*sfp)()= (int (*)())client;
  3037. X
  3038. X    if (XmToggleButtonGetState(w)) {
  3039. X        /* better turn off searching if changing the search function! */
  3040. X        if (srch_f != sfp && srching_now())
  3041. X        XmToggleButtonSetState(on_w, False, True /* invoke cb */);
  3042. X        srch_f = sfp;
  3043. X    }
  3044. X}
  3045. X
  3046. X/* callback from the on/off toggle button activate.
  3047. X */
  3048. X/* ARGSUSED */
  3049. Xstatic void
  3050. Xsrch_on_off_cb(w, client, call)
  3051. XWidget w;
  3052. XXtPointer client;
  3053. XXtPointer call;
  3054. X{
  3055. X    static char *msg =
  3056. X        "You must first successfully compile a search function and\n select a goal algorithm before searching may be enabled.";
  3057. X
  3058. X    if (XmToggleButtonGetState(w)) {
  3059. X        /* insure there is a valid function and goal algorithm selected
  3060. X         * if turning searching on.
  3061. X         */
  3062. X        if (!prog_isgood()) {
  3063. X        XmToggleButtonSetState(on_w, False, True/* invoke cb */);
  3064. X        xe_msg (msg, 0);
  3065. X         
  3066. X        } else if (srch_f == 0) {
  3067. X        XmToggleButtonSetState(on_w, False, True/* invoke cb */);
  3068. X        xe_msg (msg, 0);
  3069. X        } else {
  3070. X        srch_tmscalled = 0;
  3071. X        /* turning on searhing so as a courtesy turn off the
  3072. X         * field selection mechanism if it's on now.
  3073. X         */
  3074. X        if (XmToggleButtonGetState(field_w))
  3075. X            XmToggleButtonSetState(field_w, False, True);
  3076. X        }
  3077. X    }
  3078. X}
  3079. X
  3080. X/* use successive paraboloidal fits to find when expression is at a
  3081. X * local minimum or maximum.
  3082. X */
  3083. Xstatic
  3084. Xsrch_minmax(Mjd, v, tmincp)
  3085. Xdouble Mjd;
  3086. Xdouble v;
  3087. Xdouble *tmincp;
  3088. X{
  3089. X    static double base;        /* for better stability */
  3090. X    static double x_1, x_2, x_3;    /* keep in increasing order */
  3091. X    static double y_1, y_2, y_3;
  3092. X    double xm, a, b;
  3093. X
  3094. X    if (srch_tmscalled == 0) {
  3095. X        base = Mjd;
  3096. X        x_1 = 0.0;
  3097. X        y_1 = v;
  3098. X        return (0);
  3099. X    }
  3100. X    Mjd -= base;
  3101. X    if (srch_tmscalled == 1) {
  3102. X        /* put in one of first two slots */
  3103. X        if (Mjd < x_1) {
  3104. X            x_2 = x_1;  y_2 = y_1;
  3105. X        x_1 = Mjd; y_1 = v;
  3106. X        } else {
  3107. X        x_2 = Mjd; y_2 = v;
  3108. X        }
  3109. X        return (0);
  3110. X    }
  3111. X    if (srch_tmscalled == 2 || fabs(Mjd - x_1) < fabs(Mjd - x_3)) {
  3112. X        /* closer to x_1 so discard x_3.
  3113. X         * or if it's our third value we know to "discard" x_3.
  3114. X         */
  3115. X        if (Mjd > x_2) {
  3116. X        x_3 = Mjd; y_3 = v;
  3117. X        } else {
  3118. X        x_3 = x_2;  y_3 = y_2;
  3119. X        if (Mjd > x_1) {
  3120. X            x_2 = Mjd; y_2 = v;
  3121. X        } else {
  3122. X            x_2 = x_1;  y_2 = y_1;
  3123. X            x_1 = Mjd; y_1 = v;
  3124. X        }
  3125. X        }
  3126. X        if (srch_tmscalled == 2)
  3127. X        return (0);
  3128. X    } else {
  3129. X        /* closer to x_3 so discard x_1 */
  3130. X        if (Mjd < x_2) {
  3131. X        x_1 = Mjd;  y_1 = v;
  3132. X        } else {
  3133. X        x_1 =  x_2;  y_1 = y_2;
  3134. X        if (Mjd < x_3) {
  3135. X            x_2 = Mjd; y_2 = v;
  3136. X        } else {
  3137. X            x_2 =  x_3; y_2 = y_3;
  3138. X            x_3 = Mjd; y_3 = v;
  3139. X        }
  3140. X        }
  3141. X    }
  3142. X
  3143. X#ifdef TRACEMM
  3144. X    { char buf[NC];
  3145. X      (void) sprintf (buf, "x_1=%g y_1=%g x_2=%g y_2=%g x_3=%g y_3=%g",
  3146. X                        x_1, y_1, x_2, y_2, x_3, y_3);
  3147. X      xe_msg (buf,0);
  3148. X    }
  3149. X#endif
  3150. X    a = y_1*(x_2-x_3) - y_2*(x_1-x_3) + y_3*(x_1-x_2);
  3151. X    if (fabs(a) < 1e-10) {
  3152. X        /* near-0 zero denominator, ie, curve is pretty flat here,
  3153. X         * so assume we are done enough.
  3154. X         * signal this by forcing a 0 tminc.
  3155. X         */
  3156. X        *tmincp = 0.0;
  3157. X        return (-1);
  3158. X    }
  3159. X    b = (x_1*x_1)*(y_2-y_3) - (x_2*x_2)*(y_1-y_3) + (x_3*x_3)*(y_1-y_2);
  3160. X    xm = -b/(2.0*a);
  3161. X    *tmincp = (xm - Mjd)*24.0;
  3162. X    return (fabs (*tmincp) < tmlimit ? -1 : 0);
  3163. X}
  3164. X
  3165. X/* use secant method to solve for time when expression passes through 0.
  3166. X */
  3167. Xstatic
  3168. Xsrch_solve0(Mjd, v, tmincp)
  3169. Xdouble Mjd;
  3170. Xdouble v;
  3171. Xdouble *tmincp;
  3172. X{
  3173. X    static double x0, x_1;    /* x(n-1) and x(n) */
  3174. X    static double y_0, y_1;    /* y(n-1) and y(n) */
  3175. X    double x_2;        /* x(n+1) */
  3176. X    double df;        /* y(n) - y(n-1) */
  3177. X
  3178. X    switch (srch_tmscalled) {
  3179. X    case 0: x0 = Mjd; y_0 = v; return(0);
  3180. X    case 1: x_1 = Mjd; y_1 = v; break;
  3181. X    default: x0 = x_1; y_0 = y_1; x_1 = Mjd; y_1 = v; break;
  3182. X    }
  3183. X
  3184. X    df = y_1 - y_0;
  3185. X    if (fabs(df) < 1e-10) {
  3186. X        /* near-0 zero denominator, ie, curve is pretty flat here,
  3187. X         * so assume we are done enough.
  3188. X         * signal this by forcing a 0 tminc.
  3189. X         */
  3190. X        *tmincp = 0.0;
  3191. X        return (-1);
  3192. X    }
  3193. X    x_2 = x_1 - y_1*(x_1-x0)/df;
  3194. X    *tmincp = (x_2 - Mjd)*24.0;
  3195. X    return (fabs (*tmincp) < tmlimit ? -1 : 0);
  3196. X}
  3197. X
  3198. X/* binary search for time when expression changes from its initial state.
  3199. X * if the change is outside the initial tminc range, then keep searching in that
  3200. X *    direction by tminc first before starting to divide down.
  3201. X */
  3202. Xstatic
  3203. Xsrch_binary(Mjd, v, tmincp)
  3204. Xdouble Mjd;
  3205. Xdouble v;
  3206. Xdouble *tmincp;
  3207. X{
  3208. X    static double lb, ub;        /* lower and upper bound */
  3209. X    static int initial_state;
  3210. X    int this_state = v >= 0.5;
  3211. X
  3212. X#define    FLUNDEF    -9e10
  3213. X
  3214. X    if (srch_tmscalled == 0) {
  3215. X        if (*tmincp >= 0.0) {
  3216. X        /* going forwards in time so first Mjd is lb and no ub yet */
  3217. X        lb = Mjd;
  3218. X        ub = FLUNDEF;
  3219. X        } else {
  3220. X        /* going backwards in time so first Mjd is ub and no lb yet */
  3221. X        ub = Mjd;
  3222. X        lb = FLUNDEF;
  3223. X        }
  3224. X        initial_state = this_state;
  3225. X        return (0);
  3226. X    }
  3227. X
  3228. X    if (ub != FLUNDEF && lb != FLUNDEF) {
  3229. X        if (this_state == initial_state)
  3230. X        lb = Mjd;
  3231. X        else
  3232. X        ub = Mjd;
  3233. X        *tmincp = ((lb + ub)/2.0 - Mjd)*24.0;
  3234. X#ifdef TRACEBIN
  3235. X        { char buf[NC];
  3236. X          (void) sprintf (buf, "lb=%g ub=%g tminc=%g Mjd=%g is=%d ts=%d",
  3237. X                lb, ub, *tmincp, Mjd, initial_state, this_state);
  3238. X          xe_msg(buf, 0);
  3239. X        }
  3240. X#endif
  3241. X        /* signal to stop if asking for time change less than TMLIMIT */
  3242. X        return (fabs (*tmincp) < tmlimit ? -1 : 0);
  3243. X    } else if (this_state != initial_state) {
  3244. X        /* gone past; turn around half way */
  3245. X        if (*tmincp >= 0.0)
  3246. X        ub = Mjd;
  3247. X        else
  3248. X        lb = Mjd;
  3249. X        *tmincp /= -2.0;
  3250. X        return (0);
  3251. X    } else {
  3252. X        /* just keep going, looking for first state change but we keep
  3253. X         * learning the lower (or upper, if going backwards) bound.
  3254. X         */
  3255. X        if (*tmincp >= 0.0)
  3256. X        lb = Mjd;
  3257. X        else
  3258. X        ub = Mjd;
  3259. X        return (0);
  3260. X    }
  3261. X}
  3262. END_OF_FILE
  3263.   if test 27491 -ne `wc -c <'srchmenu.c'`; then
  3264.     echo shar: \"'srchmenu.c'\" unpacked with wrong size!
  3265.   fi
  3266.   # end of 'srchmenu.c'
  3267. fi
  3268. echo shar: End of archive 16 \(of 21\).
  3269. cp /dev/null ark16isdone
  3270. MISSING=""
  3271. for I in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 ; do
  3272.     if test ! -f ark${I}isdone ; then
  3273.     MISSING="${MISSING} ${I}"
  3274.     fi
  3275. done
  3276. if test "${MISSING}" = "" ; then
  3277.     echo You have unpacked all 21 archives.
  3278.     rm -f ark[1-9]isdone ark[1-9][0-9]isdone
  3279.     echo Building ephem.db
  3280.     cat > ephem.db.Z.uu ephem.db.Z.uu.?
  3281.     uudecode ephem.db.Z.uu
  3282.     rm ephem.db.Z.uu ephem.db.Z.uu.?
  3283.     uncompress ephem.db.Z
  3284.     echo Building skyviewmenu.c
  3285.     cat > skyviewmenu.c skyviewmenu.c.?
  3286.     rm skyviewmenu.c.?
  3287.     echo Building smallfm.xbm
  3288.     cat > smallfm.xbm smallfm.xbm.?
  3289.     rm smallfm.xbm.?
  3290. else
  3291.     echo You still must unpack the following archives:
  3292.     echo "        " ${MISSING}
  3293. fi
  3294. exit 0
  3295. exit 0 # Just in case...
  3296. -- 
  3297.   // chris@IMD.Sterling.COM            | Send comp.sources.x submissions to:
  3298. \X/  Amiga - The only way to fly!      |
  3299.  "It's intuitively obvious to the most |    sources-x@imd.sterling.com
  3300.   casual observer..."                  |
  3301.