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

  1. Newsgroups: comp.sources.x
  2. From: ecdowney@pobox.cca.cr.rockwell.com (Elwood Downey)
  3. Subject: v19i105:  xephem - astronomical ephemeris program, Part17/21
  4. Message-ID: <1993May10.221242.9478@sparky.imd.sterling.com>
  5. X-Md4-Signature: 9fffca138cecd2b2d793b3cd48700c8f
  6. Date: Mon, 10 May 1993 22:12:42 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 105
  11. Archive-name: xephem/part17
  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:  constel.c jupmenu.c skyviewmenu.c.2
  22. # Wrapped by chris@nova on Mon May 10 16:41:52 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 17 (of 21)."'
  26. if test -f 'constel.c' -a "${1}" != "-c" ; then 
  27.   echo shar: Will not clobber existing file \"'constel.c'\"
  28. else
  29.   echo shar: Extracting \"'constel.c'\" \(20349 characters\)
  30.   sed "s/^X//" >'constel.c' <<'END_OF_FILE'
  31. X#include <math.h>
  32. X#include "astro.h"
  33. X
  34. X#if defined(__STDC__) || defined(__cplusplus)
  35. X#define P_(s) s
  36. X#else
  37. X#define P_(s) ()
  38. X#endif
  39. X
  40. Xextern void cal_mjd P_((int mn, double dy, int yr, double *Mjd));
  41. Xextern void precess P_((double mjd1, double mjd2, double *ra, double *dec));
  42. X
  43. Xvoid confnd P_((double r, double d, double e, char **name));
  44. X
  45. X#undef P_
  46. X
  47. X
  48. X/*
  49. X  METHOD TO DETERMINE THE CONSTELLATION IN WHICH A POSITION IS LOCATED
  50. X
  51. XC version by Craig Counterman and Elwood Downey,
  52. Xadapted from fortran version:
  53. Xexerpt from accompanying doc file:
  54. X
  55. X        Recently, Mr. Barry N. Rappaport of New  Mexico State University
  56. X  transcribed  the constellation  boundaries as  fixed  by the IAU  into
  57. X  machine-readable form.  These have  been  transcribed  by Dr. Nancy G.
  58. X  Roman to make it possible  to determine by  computer the constellation
  59. X  in which a position is located.
  60. X
  61. XNSSDC catalog description:
  62. X 6042   AN     Catalog of Constellation Boundary Data (Delporte, E. 1930, 
  63. X               Cambridge Univ. Press)
  64. X               Comment(s): includes constellation identification software 
  65. X               (ADC 1987; see Roman, N.G. 1987, Publ. Astron. Soc. Pacific 
  66. X               99, 695); 23 description, 118 software, 358 data records. 
  67. X               3 files: 23x80, 118x80, 358x29 
  68. X
  69. Xfull documentation file:
  70. X
  71. X   METHOD TO DETERMINE THE CONSTELLATION IN WHICH A POSITION IS LOCATED
  72. X
  73. X     Recently, Mr. Barry N. Rappaport of New Mexico State University trans-
  74. Xcribed the constellation boundaries as fixed by the IAU into machine-readable
  75. Xform.  These have been transcribed by Dr. Nancy G. Roman to make it possible to
  76. Xdetermine by computer the constellation in which a position is located.
  77. X     Two files follow.  The first is a program, in FORTRAN77, for determining
  78. Xthe constellation using the data in the succeeding file.  Comments describe
  79. Xthe format in which the positions must be entered.  The main program is
  80. Xfollowed by a precession subroutine.
  81. X     The final file is a list of constellation boundaries in the form Lower
  82. XRight Ascension (F8.4), Upper Right Ascension (F8.4), Lower Declination (F9.4),
  83. Xthree letter abbreviation for the Constellation (1X,A3).  The file contains
  84. X358, 29-byte records.
  85. X    The following is an example of the output of the program:
  86. X RA =  9.0000 DEC =  65.0000  IS IN CONSTELLATION UMa
  87. X RA = 23.5000 DEC = -20.0000  IS IN CONSTELLATION Aqr
  88. X RA =  5.1200 DEC =   9.1200  IS IN CONSTELLATION Ori
  89. X RA =  9.4555 DEC = -19.9000  IS IN CONSTELLATION Hya
  90. X RA = 12.8888 DEC =  22.0000  IS IN CONSTELLATION Com
  91. X RA = 15.6687 DEC = -12.1234  IS IN CONSTELLATION Lib
  92. X RA = 19.0000 DEC = -40.0000  IS IN CONSTELLATION CrA
  93. X RA =  6.2222 DEC = -81.1234  IS IN CONSTELLATION Men
  94. X END OF INPUT POSITIONS AFTER: RA =   6.2222   DEC = -81.1234
  95. X THE EQUINOX FOR THESE POSITIONS IS 1950.0
  96. X*/
  97. X
  98. Xstatic char And[] = "And: Andromeda";
  99. Xstatic char Ant[] = "Ant: Antlia";
  100. Xstatic char Aps[] = "Aps: Apus";
  101. Xstatic char Aql[] = "Aql: Aquila";
  102. Xstatic char Aqr[] = "Aqr: Aquarius";
  103. Xstatic char Ara[] = "Ara: Ara";
  104. Xstatic char Ari[] = "Ari: Aries";
  105. Xstatic char Aur[] = "Aur: Auriga";
  106. Xstatic char Boo[] = "Boo: Bootes";
  107. Xstatic char CMa[] = "CMa: Canis Major";
  108. Xstatic char CMi[] = "CMi: Canis Minor";
  109. Xstatic char CVn[] = "CVn: Canes Venatici";
  110. Xstatic char Cae[] = "Cae: Caelum";
  111. Xstatic char Cam[] = "Cam: Camelopardalis";
  112. Xstatic char Cap[] = "Cap: Capricornus";
  113. Xstatic char Car[] = "Car: Carina";
  114. Xstatic char Cas[] = "Cas: Cassiopeia";
  115. Xstatic char Cen[] = "Cen: Centaurus";
  116. Xstatic char Cep[] = "Cep: Cepheus";
  117. Xstatic char Cet[] = "Cet: Cetus";
  118. Xstatic char Cha[] = "Cha: Chamaeleon";
  119. Xstatic char Cir[] = "Cir: Circinus";
  120. Xstatic char Cnc[] = "Cnc: Cancer";
  121. Xstatic char Col[] = "Col: Columba";
  122. Xstatic char Com[] = "Com: Coma Berenices";
  123. Xstatic char CrA[] = "CrA: Corona Australis";
  124. Xstatic char CrB[] = "CrB: Corona Borealis";
  125. Xstatic char Crt[] = "Crt: Crater";
  126. Xstatic char Cru[] = "Cru: Crux";
  127. Xstatic char Crv[] = "Crv: Corvus";
  128. Xstatic char Cyg[] = "Cyg: Cygnus";
  129. Xstatic char Del[] = "Del: Delphinus";
  130. Xstatic char Dor[] = "Dor: Dorado";
  131. Xstatic char Dra[] = "Dra: Draco";
  132. Xstatic char Equ[] = "Equ: Equuleus";
  133. Xstatic char Eri[] = "Eri: Eridanus";
  134. Xstatic char For[] = "For: Fornax";
  135. Xstatic char Gem[] = "Gem: Gemini";
  136. Xstatic char Gru[] = "Gru: Grus";
  137. Xstatic char Her[] = "Her: Hercules";
  138. Xstatic char Hor[] = "Hor: Horologium";
  139. Xstatic char Hya[] = "Hya: Hydra";
  140. Xstatic char Hyi[] = "Hyi: Hydrus";
  141. Xstatic char Ind[] = "Ind: Indus";
  142. Xstatic char LMi[] = "LMi: Leo Minor";
  143. Xstatic char Lac[] = "Lac: Lacerta";
  144. Xstatic char Leo[] = "Leo: Leo";
  145. Xstatic char Lep[] = "Lep: Lepus";
  146. Xstatic char Lib[] = "Lib: Libra";
  147. Xstatic char Lup[] = "Lup: Lupus";
  148. Xstatic char Lyn[] = "Lyn: Lynx";
  149. Xstatic char Lyr[] = "Lyr: Lyra";
  150. Xstatic char Men[] = "Men: Mensa";
  151. Xstatic char Mic[] = "Mic: Microscopium";
  152. Xstatic char Mon[] = "Mon: Monoceros";
  153. Xstatic char Mus[] = "Mus: Musca";
  154. Xstatic char Nor[] = "Nor: Norma";
  155. Xstatic char Oct[] = "Oct: Octans";
  156. Xstatic char Oph[] = "Oph: Ophiuchus";
  157. Xstatic char Ori[] = "Ori: Orion";
  158. Xstatic char Pav[] = "Pav: Pavo";
  159. Xstatic char Peg[] = "Peg: Pegasus";
  160. Xstatic char Per[] = "Per: Perseus";
  161. Xstatic char Phe[] = "Phe: Phoenix";
  162. Xstatic char Pic[] = "Pic: Pictor";
  163. Xstatic char PsA[] = "PsA: Piscis Austrinus";
  164. Xstatic char Psc[] = "Psc: Pisces";
  165. Xstatic char Pup[] = "Pup: Puppis";
  166. Xstatic char Pyx[] = "Pyx: Pyxis";
  167. Xstatic char Ret[] = "Ret: Reticulum";
  168. Xstatic char Scl[] = "Scl: Sculptor";
  169. Xstatic char Sco[] = "Sco: Scorpius";
  170. Xstatic char Sct[] = "Sct: Scutum";
  171. Xstatic char Ser[] = "Ser: Serpens";
  172. Xstatic char Sex[] = "Sex: Sextans";
  173. Xstatic char Sge[] = "Sge: Sagitta";
  174. Xstatic char Sgr[] = "Sgr: Sagittarius";
  175. Xstatic char Tau[] = "Tau: Taurus";
  176. Xstatic char Tel[] = "Tel: Telescopium";
  177. Xstatic char TrA[] = "TrA: Triangulum Australe";
  178. Xstatic char Tri[] = "Tri: Triangulum";
  179. Xstatic char Tuc[] = "Tuc: Tucana";
  180. Xstatic char UMa[] = "UMa: Ursa Major";
  181. Xstatic char UMi[] = "UMi: Ursa Minor";
  182. Xstatic char Vel[] = "Vel: Vela";
  183. Xstatic char Vir[] = "Vir: Virgo";
  184. Xstatic char Vol[] = "Vol: Volans";
  185. Xstatic char Vul[] = "Vul: Vulpecula";
  186. X
  187. Xstatic struct cdata {
  188. X    double l_ra, u_ra, l_dec;
  189. X    char *cons;
  190. X} con_data[] = {
  191. X    {0.0000, 24.0000, 88.0000, UMi},
  192. X    {8.0000, 14.5000, 86.5000, UMi},
  193. X    {21.0000, 23.0000, 86.1667, UMi},
  194. X    {18.0000, 21.0000, 86.0000, UMi},
  195. X    {0.0000, 8.0000, 85.0000, Cep},
  196. X    {9.1667, 10.6667, 82.0000, Cam},
  197. X    {0.0000, 5.0000, 80.0000, Cep},
  198. X    {10.6667, 14.5000, 80.0000, Cam},
  199. X    {17.5000, 18.0000, 80.0000, UMi},
  200. X    {20.1667, 21.0000, 80.0000, Dra},
  201. X    {0.0000, 3.5083, 77.0000, Cep},
  202. X    {11.5000, 13.5833, 77.0000, Cam},
  203. X    {16.5333, 17.5000, 75.0000, UMi},
  204. X    {20.1667, 20.6667, 75.0000, Cep},
  205. X    {7.9667, 9.1667, 73.5000, Cam},
  206. X    {9.1667, 11.3333, 73.5000, Dra},
  207. X    {13.0000, 16.5333, 70.0000, UMi},
  208. X    {3.1000, 3.4167, 68.0000, Cas},
  209. X    {20.4167, 20.6667, 67.0000, Dra},
  210. X    {11.3333, 12.0000, 66.5000, Dra},
  211. X    {0.0000, 0.3333, 66.0000, Cep},
  212. X    {14.0000, 15.6667, 66.0000, UMi},
  213. X    {23.5833, 24.0000, 66.0000, Cep},
  214. X    {12.0000, 13.5000, 64.0000, Dra},
  215. X    {13.5000, 14.4167, 63.0000, Dra},
  216. X    {23.1667, 23.5833, 63.0000, Cep},
  217. X    {6.1000, 7.0000, 62.0000, Cam},
  218. X    {20.0000, 20.4167, 61.5000, Dra},
  219. X    {20.5367, 20.6000, 60.9167, Cep},
  220. X    {7.0000, 7.9667, 60.0000, Cam},
  221. X    {7.9667, 8.4167, 60.0000, UMa},
  222. X    {19.7667, 20.0000, 59.5000, Dra},
  223. X    {20.0000, 20.5367, 59.5000, Cep},
  224. X    {22.8667, 23.1667, 59.0833, Cep},
  225. X    {0.0000, 2.4333, 58.5000, Cas},
  226. X    {19.4167, 19.7667, 58.0000, Dra},
  227. X    {1.7000, 1.9083, 57.5000, Cas},
  228. X    {2.4333, 3.1000, 57.0000, Cas},
  229. X    {3.1000, 3.1667, 57.0000, Cam},
  230. X    {22.3167, 22.8667, 56.2500, Cep},
  231. X    {5.0000, 6.1000, 56.0000, Cam},
  232. X    {14.0333, 14.4167, 55.5000, UMa},
  233. X    {14.4167, 19.4167, 55.5000, Dra},
  234. X    {3.1667, 3.3333, 55.0000, Cam},
  235. X    {22.1333, 22.3167, 55.0000, Cep},
  236. X    {20.6000, 21.9667, 54.8333, Cep},
  237. X    {0.0000, 1.7000, 54.0000, Cas},
  238. X    {6.1000, 6.5000, 54.0000, Lyn},
  239. X    {12.0833, 13.5000, 53.0000, UMa},
  240. X    {15.2500, 15.7500, 53.0000, Dra},
  241. X    {21.9667, 22.1333, 52.7500, Cep},
  242. X    {3.3333, 5.0000, 52.5000, Cam},
  243. X    {22.8667, 23.3333, 52.5000, Cas},
  244. X    {15.7500, 17.0000, 51.5000, Dra},
  245. X    {2.0417, 2.5167, 50.5000, Per},
  246. X    {17.0000, 18.2333, 50.5000, Dra},
  247. X    {0.0000, 1.3667, 50.0000, Cas},
  248. X    {1.3667, 1.6667, 50.0000, Per},
  249. X    {6.5000, 6.8000, 50.0000, Lyn},
  250. X    {23.3333, 24.0000, 50.0000, Cas},
  251. X    {13.5000, 14.0333, 48.5000, UMa},
  252. X    {0.0000, 1.1167, 48.0000, Cas},
  253. X    {23.5833, 24.0000, 48.0000, Cas},
  254. X    {18.1750, 18.2333, 47.5000, Her},
  255. X    {18.2333, 19.0833, 47.5000, Dra},
  256. X    {19.0833, 19.1667, 47.5000, Cyg},
  257. X    {1.6667, 2.0417, 47.0000, Per},
  258. X    {8.4167, 9.1667, 47.0000, UMa},
  259. X    {0.1667, 0.8667, 46.0000, Cas},
  260. X    {12.0000, 12.0833, 45.0000, UMa},
  261. X    {6.8000, 7.3667, 44.5000, Lyn},
  262. X    {21.9083, 21.9667, 44.0000, Cyg},
  263. X    {21.8750, 21.9083, 43.7500, Cyg},
  264. X    {19.1667, 19.4000, 43.5000, Cyg},
  265. X    {9.1667, 10.1667, 42.0000, UMa},
  266. X    {10.1667, 10.7833, 40.0000, UMa},
  267. X    {15.4333, 15.7500, 40.0000, Boo},
  268. X    {15.7500, 16.3333, 40.0000, Her},
  269. X    {9.2500, 9.5833, 39.7500, Lyn},
  270. X    {0.0000, 2.5167, 36.7500, And},
  271. X    {2.5167, 2.5667, 36.7500, Per},
  272. X    {19.3583, 19.4000, 36.5000, Lyr},
  273. X    {4.5000, 4.6917, 36.0000, Per},
  274. X    {21.7333, 21.8750, 36.0000, Cyg},
  275. X    {21.8750, 22.0000, 36.0000, Lac},
  276. X    {6.5333, 7.3667, 35.5000, Aur},
  277. X    {7.3667, 7.7500, 35.5000, Lyn},
  278. X    {0.0000, 2.0000, 35.0000, And},
  279. X    {22.0000, 22.8167, 35.0000, Lac},
  280. X    {22.8167, 22.8667, 34.5000, Lac},
  281. X    {22.8667, 23.5000, 34.5000, And},
  282. X    {2.5667, 2.7167, 34.0000, Per},
  283. X    {10.7833, 11.0000, 34.0000, UMa},
  284. X    {12.0000, 12.3333, 34.0000, CVn},
  285. X    {7.7500, 9.2500, 33.5000, Lyn},
  286. X    {9.2500, 9.8833, 33.5000, LMi},
  287. X    {0.7167, 1.4083, 33.0000, And},
  288. X    {15.1833, 15.4333, 33.0000, Boo},
  289. X    {23.5000, 23.7500, 32.0833, And},
  290. X    {12.3333, 13.2500, 32.0000, CVn},
  291. X    {23.7500, 24.0000, 31.3333, And},
  292. X    {13.9583, 14.0333, 30.7500, CVn},
  293. X    {2.4167, 2.7167, 30.6667, Tri},
  294. X    {2.7167, 4.5000, 30.6667, Per},
  295. X    {4.5000, 4.7500, 30.0000, Aur},
  296. X    {18.1750, 19.3583, 30.0000, Lyr},
  297. X    {11.0000, 12.0000, 29.0000, UMa},
  298. X    {19.6667, 20.9167, 29.0000, Cyg},
  299. X    {4.7500, 5.8833, 28.5000, Aur},
  300. X    {9.8833, 10.5000, 28.5000, LMi},
  301. X    {13.2500, 13.9583, 28.5000, CVn},
  302. X    {0.0000, 0.0667, 28.0000, And},
  303. X    {1.4083, 1.6667, 28.0000, Tri},
  304. X    {5.8833, 6.5333, 28.0000, Aur},
  305. X    {7.8833, 8.0000, 28.0000, Gem},
  306. X    {20.9167, 21.7333, 28.0000, Cyg},
  307. X    {19.2583, 19.6667, 27.5000, Cyg},
  308. X    {1.9167, 2.4167, 27.2500, Tri},
  309. X    {16.1667, 16.3333, 27.0000, CrB},
  310. X    {15.0833, 15.1833, 26.0000, Boo},
  311. X    {15.1833, 16.1667, 26.0000, CrB},
  312. X    {18.3667, 18.8667, 26.0000, Lyr},
  313. X    {10.7500, 11.0000, 25.5000, LMi},
  314. X    {18.8667, 19.2583, 25.5000, Lyr},
  315. X    {1.6667, 1.9167, 25.0000, Tri},
  316. X    {0.7167, 0.8500, 23.7500, Psc},
  317. X    {10.5000, 10.7500, 23.5000, LMi},
  318. X    {21.2500, 21.4167, 23.5000, Vul},
  319. X    {5.7000, 5.8833, 22.8333, Tau},
  320. X    {0.0667, 0.1417, 22.0000, And},
  321. X    {15.9167, 16.0333, 22.0000, Ser},
  322. X    {5.8833, 6.2167, 21.5000, Gem},
  323. X    {19.8333, 20.2500, 21.2500, Vul},
  324. X    {18.8667, 19.2500, 21.0833, Vul},
  325. X    {0.1417, 0.8500, 21.0000, And},
  326. X    {20.2500, 20.5667, 20.5000, Vul},
  327. X    {7.8083, 7.8833, 20.0000, Gem},
  328. X    {20.5667, 21.2500, 19.5000, Vul},
  329. X    {19.2500, 19.8333, 19.1667, Vul},
  330. X    {3.2833, 3.3667, 19.0000, Ari},
  331. X    {18.8667, 19.0000, 18.5000, Sge},
  332. X    {5.7000, 5.7667, 18.0000, Ori},
  333. X    {6.2167, 6.3083, 17.5000, Gem},
  334. X    {19.0000, 19.8333, 16.1667, Sge},
  335. X    {4.9667, 5.3333, 16.0000, Tau},
  336. X    {15.9167, 16.0833, 16.0000, Her},
  337. X    {19.8333, 20.2500, 15.7500, Sge},
  338. X    {4.6167, 4.9667, 15.5000, Tau},
  339. X    {5.3333, 5.6000, 15.5000, Tau},
  340. X    {12.8333, 13.5000, 15.0000, Com},
  341. X    {17.2500, 18.2500, 14.3333, Her},
  342. X    {11.8667, 12.8333, 14.0000, Com},
  343. X    {7.5000, 7.8083, 13.5000, Gem},
  344. X    {16.7500, 17.2500, 12.8333, Her},
  345. X    {0.0000, 0.1417, 12.5000, Peg},
  346. X    {5.6000, 5.7667, 12.5000, Tau},
  347. X    {7.0000, 7.5000, 12.5000, Gem},
  348. X    {21.1167, 21.3333, 12.5000, Peg},
  349. X    {6.3083, 6.9333, 12.0000, Gem},
  350. X    {18.2500, 18.8667, 12.0000, Her},
  351. X    {20.8750, 21.0500, 11.8333, Del},
  352. X    {21.0500, 21.1167, 11.8333, Peg},
  353. X    {11.5167, 11.8667, 11.0000, Leo},
  354. X    {6.2417, 6.3083, 10.0000, Ori},
  355. X    {6.9333, 7.0000, 10.0000, Gem},
  356. X    {7.8083, 7.9250, 10.0000, Cnc},
  357. X    {23.8333, 24.0000, 10.0000, Peg},
  358. X    {1.6667, 3.2833,  9.9167, Ari},
  359. X    {20.1417, 20.3000,  8.5000, Del},
  360. X    {13.5000, 15.0833,  8.0000, Boo},
  361. X    {22.7500, 23.8333,  7.5000, Peg},
  362. X    {7.9250, 9.2500,  7.0000, Cnc},
  363. X    {9.2500, 10.7500,  7.0000, Leo},
  364. X    {18.2500, 18.6622,  6.2500, Oph},
  365. X    {18.6622, 18.8667,  6.2500, Aql},
  366. X    {20.8333, 20.8750,  6.0000, Del},
  367. X    {7.0000, 7.0167,  5.5000, CMi},
  368. X    {18.2500, 18.4250,  4.5000, Ser},
  369. X    {16.0833, 16.7500,  4.0000, Her},
  370. X    {18.2500, 18.4250,  3.0000, Oph},
  371. X    {21.4667, 21.6667,  2.7500, Peg},
  372. X    {0.0000, 2.0000,  2.0000, Psc},
  373. X    {18.5833, 18.8667,  2.0000, Ser},
  374. X    {20.3000, 20.8333,  2.0000, Del},
  375. X    {20.8333, 21.3333,  2.0000, Equ},
  376. X    {21.3333, 21.4667,  2.0000, Peg},
  377. X    {22.0000, 22.7500,  2.0000, Peg},
  378. X    {21.6667, 22.0000,  1.7500, Peg},
  379. X    {7.0167, 7.2000,  1.5000, CMi},
  380. X    {3.5833, 4.6167,  0.0000, Tau},
  381. X    {4.6167, 4.6667,  0.0000, Ori},
  382. X    {7.2000, 8.0833,  0.0000, CMi},
  383. X    {14.6667, 15.0833,  0.0000, Vir},
  384. X    {17.8333, 18.2500,  0.0000, Oph},
  385. X    {2.6500, 3.2833, -1.7500, Cet},
  386. X    {3.2833, 3.5833, -1.7500, Tau},
  387. X    {15.0833, 16.2667, -3.2500, Ser},
  388. X    {4.6667, 5.0833, -4.0000, Ori},
  389. X    {5.8333, 6.2417, -4.0000, Ori},
  390. X    {17.8333, 17.9667, -4.0000, Ser},
  391. X    {18.2500, 18.5833, -4.0000, Ser},
  392. X    {18.5833, 18.8667, -4.0000, Aql},
  393. X    {22.7500, 23.8333, -4.0000, Psc},
  394. X    {10.7500, 11.5167, -6.0000, Leo},
  395. X    {11.5167, 11.8333, -6.0000, Vir},
  396. X    {0.0000, 0.3333, -7.0000, Psc},
  397. X    {23.8333, 24.0000, -7.0000, Psc},
  398. X    {14.2500, 14.6667, -8.0000, Vir},
  399. X    {15.9167, 16.2667, -8.0000, Oph},
  400. X    {20.0000, 20.5333, -9.0000, Aql},
  401. X    {21.3333, 21.8667, -9.0000, Aqr},
  402. X    {17.1667, 17.9667, -10.0000, Oph},
  403. X    {5.8333, 8.0833, -11.0000, Mon},
  404. X    {4.9167, 5.0833, -11.0000, Eri},
  405. X    {5.0833, 5.8333, -11.0000, Ori},
  406. X    {8.0833, 8.3667, -11.0000, Hya},
  407. X    {9.5833, 10.7500, -11.0000, Sex},
  408. X    {11.8333, 12.8333, -11.0000, Vir},
  409. X    {17.5833, 17.6667, -11.6667, Oph},
  410. X    {18.8667, 20.0000, -12.0333, Aql},
  411. X    {4.8333, 4.9167, -14.5000, Eri},
  412. X    {20.5333, 21.3333, -15.0000, Aqr},
  413. X    {17.1667, 18.2500, -16.0000, Ser},
  414. X    {18.2500, 18.8667, -16.0000, Sct},
  415. X    {8.3667, 8.5833, -17.0000, Hya},
  416. X    {16.2667, 16.3750, -18.2500, Oph},
  417. X    {8.5833, 9.0833, -19.0000, Hya},
  418. X    {10.7500, 10.8333, -19.0000, Crt},
  419. X    {16.2667, 16.3750, -19.2500, Oph},
  420. X    {15.6667, 15.9167, -20.0000, Lib},
  421. X    {12.5833, 12.8333, -22.0000, Crv},
  422. X    {12.8333, 14.2500, -22.0000, Vir},
  423. X    {9.0833, 9.7500, -24.0000, Hya},
  424. X    {1.6667, 2.6500, -24.3833, Cet},
  425. X    {2.6500, 3.7500, -24.3833, Eri},
  426. X    {10.8333, 11.8333, -24.5000, Crt},
  427. X    {11.8333, 12.5833, -24.5000, Crv},
  428. X    {14.2500, 14.9167, -24.5000, Lib},
  429. X    {16.2667, 16.7500, -24.5833, Oph},
  430. X    {0.0000, 1.6667, -25.5000, Cet},
  431. X    {21.3333, 21.8667, -25.5000, Cap},
  432. X    {21.8667, 23.8333, -25.5000, Aqr},
  433. X    {23.8333, 24.0000, -25.5000, Cet},
  434. X    {9.7500, 10.2500, -26.5000, Hya},
  435. X    {4.7000, 4.8333, -27.2500, Eri},
  436. X    {4.8333, 6.1167, -27.2500, Lep},
  437. X    {20.0000, 21.3333, -28.0000, Cap},
  438. X    {10.2500, 10.5833, -29.1667, Hya},
  439. X    {12.5833, 14.9167, -29.5000, Hya},
  440. X    {14.9167, 15.6667, -29.5000, Lib},
  441. X    {15.6667, 16.0000, -29.5000, Sco},
  442. X    {4.5833, 4.7000, -30.0000, Eri},
  443. X    {16.7500, 17.6000, -30.0000, Oph},
  444. X    {17.6000, 17.8333, -30.0000, Sgr},
  445. X    {10.5833, 10.8333, -31.1667, Hya},
  446. X    {6.1167, 7.3667, -33.0000, CMa},
  447. X    {12.2500, 12.5833, -33.0000, Hya},
  448. X    {10.8333, 12.2500, -35.0000, Hya},
  449. X    {3.5000, 3.7500, -36.0000, For},
  450. X    {8.3667, 9.3667, -36.7500, Pyx},
  451. X    {4.2667, 4.5833, -37.0000, Eri},
  452. X    {17.8333, 19.1667, -37.0000, Sgr},
  453. X    {21.3333, 23.0000, -37.0000, PsA},
  454. X    {23.0000, 23.3333, -37.0000, Scl},
  455. X    {3.0000, 3.5000, -39.5833, For},
  456. X    {9.3667, 11.0000, -39.7500, Ant},
  457. X    {0.0000, 1.6667, -40.0000, Scl},
  458. X    {1.6667, 3.0000, -40.0000, For},
  459. X    {3.8667, 4.2667, -40.0000, Eri},
  460. X    {23.3333, 24.0000, -40.0000, Scl},
  461. X    {14.1667, 14.9167, -42.0000, Cen},
  462. X    {15.6667, 16.0000, -42.0000, Lup},
  463. X    {16.0000, 16.4208, -42.0000, Sco},
  464. X    {4.8333, 5.0000, -43.0000, Cae},
  465. X    {5.0000, 6.5833, -43.0000, Col},
  466. X    {8.0000, 8.3667, -43.0000, Pup},
  467. X    {3.4167, 3.8667, -44.0000, Eri},
  468. X    {16.4208, 17.8333, -45.5000, Sco},
  469. X    {17.8333, 19.1667, -45.5000, CrA},
  470. X    {19.1667, 20.3333, -45.5000, Sgr},
  471. X    {20.3333, 21.3333, -45.5000, Mic},
  472. X    {3.0000, 3.4167, -46.0000, Eri},
  473. X    {4.5000, 4.8333, -46.5000, Cae},
  474. X    {15.3333, 15.6667, -48.0000, Lup},
  475. X    {0.0000, 2.3333, -48.1667, Phe},
  476. X    {2.6667, 3.0000, -49.0000, Eri},
  477. X    {4.0833, 4.2667, -49.0000, Hor},
  478. X    {4.2667, 4.5000, -49.0000, Cae},
  479. X    {21.3333, 22.0000, -50.0000, Gru},
  480. X    {6.0000, 8.0000, -50.7500, Pup},
  481. X    {8.0000, 8.1667, -50.7500, Vel},
  482. X    {2.4167, 2.6667, -51.0000, Eri},
  483. X    {3.8333, 4.0833, -51.0000, Hor},
  484. X    {0.0000, 1.8333, -51.5000, Phe},
  485. X    {6.0000, 6.1667, -52.5000, Car},
  486. X    {8.1667, 8.4500, -53.0000, Vel},
  487. X    {3.5000, 3.8333, -53.1667, Hor},
  488. X    {3.8333, 4.0000, -53.1667, Dor},
  489. X    {0.0000, 1.5833, -53.5000, Phe},
  490. X    {2.1667, 2.4167, -54.0000, Eri},
  491. X    {4.5000, 5.0000, -54.0000, Pic},
  492. X    {15.0500, 15.3333, -54.0000, Lup},
  493. X    {8.4500, 8.8333, -54.5000, Vel},
  494. X    {6.1667, 6.5000, -55.0000, Car},
  495. X    {11.8333, 12.8333, -55.0000, Cen},
  496. X    {14.1667, 15.0500, -55.0000, Lup},
  497. X    {15.0500, 15.3333, -55.0000, Nor},
  498. X    {4.0000, 4.3333, -56.5000, Dor},
  499. X    {8.8333, 11.0000, -56.5000, Vel},
  500. X    {11.0000, 11.2500, -56.5000, Cen},
  501. X    {17.5000, 18.0000, -57.0000, Ara},
  502. X    {18.0000, 20.3333, -57.0000, Tel},
  503. X    {22.0000, 23.3333, -57.0000, Gru},
  504. X    {3.2000, 3.5000, -57.5000, Hor},
  505. X    {5.0000, 5.5000, -57.5000, Pic},
  506. X    {6.5000, 6.8333, -58.0000, Car},
  507. X    {0.0000, 1.3333, -58.5000, Phe},
  508. X    {1.3333, 2.1667, -58.5000, Eri},
  509. X    {23.3333, 24.0000, -58.5000, Phe},
  510. X    {4.3333, 4.5833, -59.0000, Dor},
  511. X    {15.3333, 16.4208, -60.0000, Nor},
  512. X    {20.3333, 21.3333, -60.0000, Ind},
  513. X    {5.5000, 6.0000, -61.0000, Pic},
  514. X    {15.1667, 15.3333, -61.0000, Cir},
  515. X    {16.4208, 16.5833, -61.0000, Ara},
  516. X    {14.9167, 15.1667, -63.5833, Cir},
  517. X    {16.5833, 16.7500, -63.5833, Ara},
  518. X    {6.0000, 6.8333, -64.0000, Pic},
  519. X    {6.8333, 9.0333, -64.0000, Car},
  520. X    {11.2500, 11.8333, -64.0000, Cen},
  521. X    {11.8333, 12.8333, -64.0000, Cru},
  522. X    {12.8333, 14.5333, -64.0000, Cen},
  523. X    {13.5000, 13.6667, -65.0000, Cir},
  524. X    {16.7500, 16.8333, -65.0000, Ara},
  525. X    {2.1667, 3.2000, -67.5000, Hor},
  526. X    {3.2000, 4.5833, -67.5000, Ret},
  527. X    {14.7500, 14.9167, -67.5000, Cir},
  528. X    {16.8333, 17.5000, -67.5000, Ara},
  529. X    {17.5000, 18.0000, -67.5000, Pav},
  530. X    {22.0000, 23.3333, -67.5000, Tuc},
  531. X    {4.5833, 6.5833, -70.0000, Dor},
  532. X    {13.6667, 14.7500, -70.0000, Cir},
  533. X    {14.7500, 17.0000, -70.0000, TrA},
  534. X    {0.0000, 1.3333, -75.0000, Tuc},
  535. X    {3.5000, 4.5833, -75.0000, Hyi},
  536. X    {6.5833, 9.0333, -75.0000, Vol},
  537. X    {9.0333, 11.2500, -75.0000, Car},
  538. X    {11.2500, 13.6667, -75.0000, Mus},
  539. X    {18.0000, 21.3333, -75.0000, Pav},
  540. X    {21.3333, 23.3333, -75.0000, Ind},
  541. X    {23.3333, 24.0000, -75.0000, Tuc},
  542. X    {0.7500, 1.3333, -76.0000, Tuc},
  543. X    {0.0000, 3.5000, -82.5000, Hyi},
  544. X    {7.6667, 13.6667, -82.5000, Cha},
  545. X    {13.6667, 18.0000, -82.5000, Aps},
  546. X    {3.5000, 7.6667, -85.0000, Men},
  547. X    {0.0000, 24.0000, -90.0000, Oct},
  548. X    {0.0000, 24.0000, -90.0000, ""}
  549. X};
  550. X
  551. X/* given ra and dec (in rads) precessed to epoch e (an mjd)
  552. X * point *name to a string naming the constellation at that location.
  553. X */
  554. Xvoid
  555. Xconfnd(r, d, e, name)
  556. Xdouble r, d, e;
  557. Xchar **name;
  558. X{
  559. X    double ra1875, de1875, mjd1875;
  560. X    int i;
  561. X
  562. X    cal_mjd (1, 1.0, 1875, &mjd1875);
  563. X    precess (e, mjd1875, &r, &d);
  564. X        
  565. X    /* find constellation such that the declination entered is higher than
  566. X     * the lower boundary of the constellation when the upper and lower
  567. X     * right ascensions for the constellation bound the entered right
  568. X     * ascension
  569. X     */
  570. X    i = 0;
  571. X    ra1875 = radhr (r);
  572. X    de1875 = raddeg (d);
  573. X    while ((con_data[i].l_dec > de1875 || con_data[i].u_ra <= ra1875
  574. X             || con_data[i].l_ra > ra1875) && con_data[i].cons[0])
  575. X         i++;
  576. X
  577. X    *name = con_data[i].cons[0] ? con_data[i].cons : "<No constellation?!>";
  578. X}
  579. END_OF_FILE
  580.   if test 20349 -ne `wc -c <'constel.c'`; then
  581.     echo shar: \"'constel.c'\" unpacked with wrong size!
  582.   fi
  583.   # end of 'constel.c'
  584. fi
  585. if test -f 'jupmenu.c' -a "${1}" != "-c" ; then 
  586.   echo shar: Will not clobber existing file \"'jupmenu.c'\"
  587. else
  588.   echo shar: Extracting \"'jupmenu.c'\" \(26718 characters\)
  589.   sed "s/^X//" >'jupmenu.c' <<'END_OF_FILE'
  590. X/* code to manage the stuff on the "jupiter" menu.
  591. X */
  592. X
  593. X#include <stdio.h>
  594. X#include <ctype.h>
  595. X#include <math.h>
  596. X#if defined(__STDC__)
  597. X#include <stdlib.h>
  598. X#endif
  599. X#include <X11/Xlib.h>
  600. X#include <Xm/Xm.h>
  601. X#include <Xm/Form.h>
  602. X#include <Xm/Frame.h>
  603. X#include <Xm/Label.h>
  604. X#include <Xm/PushB.h>
  605. X#include <Xm/RowColumn.h>
  606. X#include <Xm/DrawingA.h>
  607. X#include <Xm/ToggleB.h>
  608. X#include <Xm/Scale.h>
  609. X#include "astro.h"
  610. X#include "circum.h"
  611. X
  612. X
  613. Xtypedef struct {
  614. X    double x, y, z;
  615. X} MoonData;
  616. X
  617. X#if defined(__STDC__) || defined(__cplusplus)
  618. X#define P_(s) s
  619. X#else
  620. X#define P_(s) ()
  621. X#endif
  622. X
  623. Xextern Now *mm_get_now P_((void));
  624. Xextern int any_ison P_((void));
  625. Xextern void f_double P_((Widget w, char *fmt, double f));
  626. Xextern void get_something P_((Widget w, char *resource, char *value));
  627. Xextern void range P_((double *v, double r));
  628. Xextern void register_selection P_((char *name));
  629. Xextern void set_xmstring P_((Widget w, char *resource, char *txt));
  630. Xextern void timestamp P_((Now *np, Widget w));
  631. X
  632. Xvoid jm_manage P_((void));
  633. Xint jm_ison P_((void));
  634. Xvoid jm_selection_mode P_((int whether));
  635. Xvoid jm_update P_((Now *np, int how_much));
  636. Xvoid jm_cursor P_((Cursor c));
  637. Xstatic void jm_create_form_w P_((void));
  638. Xstatic void jm_set_buttons P_((int whether));
  639. Xstatic void jm_set_a_button P_((Widget pbw, int whether));
  640. Xstatic void jm_bigd_cb P_((Widget w, XtPointer client, XtPointer call));
  641. Xstatic void jm_tags_cb P_((Widget w, XtPointer client, XtPointer call));
  642. Xstatic void jm_scale_cb P_((Widget w, XtPointer client, XtPointer call));
  643. Xstatic void jm_activate_cb P_((Widget w, XtPointer client, XtPointer call));
  644. Xstatic void jm_close_cb P_((Widget w, XtPointer client, XtPointer call));
  645. Xstatic void jm_da_exp_cb P_((Widget w, XtPointer client, XtPointer call));
  646. Xstatic void jm_draw_map P_((Widget w, MoonData moons[4], double sIcml, double sIIcml));
  647. Xstatic void jupinfo P_((double d, MoonData moons[4], double *sIcml, double *sIIcml));
  648. X
  649. X#undef P_
  650. X
  651. Xextern Widget toplevel_w;
  652. X#define    XtD    XtDisplay(toplevel_w)
  653. X
  654. Xstatic Widget jupform_w;    /* main form */
  655. Xstatic Widget jda_w;        /* drawing area */
  656. Xstatic Widget cml_w[2];        /* display widgets for CMLs */
  657. Xstatic Widget scale_w;        /* size scale */
  658. Xstatic Widget dt_w;        /* date/time stamp widget */
  659. Xenum {CMLI, CMLII};        /* cml indexes */
  660. X#define    NM    4        /* number of moons */
  661. Xstatic Widget j_w[NM][3];    /* the data display widgets */
  662. Xenum {X, Y, Z};            /* j_w column index */
  663. Xstatic int jm_selecting;    /* set while our fields are being selected */
  664. Xstatic int bigdots;        /* whether we want big dots */
  665. Xstatic int j_tags;        /* whether we want tags on the drawing */
  666. X
  667. X#define    MAXSCALE    10.0    /* max scale mag factor */
  668. X
  669. Xstatic struct MoonNames {
  670. X    char *full;
  671. X    char *tag;
  672. X} mnames[NM] = {
  673. X    {"Io", "I"},
  674. X    {"Europa", "II"},
  675. X    {"Ganymede", "III"},
  676. X    {"Callisto", "IV"}
  677. X};
  678. X
  679. X/* called when the jupiter menu is activated via the main menu pulldown.
  680. X * if never called before, create and manage all the widgets as a child of a
  681. X * form. otherwise, just toggle whether the form is managed.
  682. X */
  683. Xvoid
  684. Xjm_manage ()
  685. X{
  686. X    if (!jupform_w)
  687. X        jm_create_form_w();
  688. X    
  689. X    if (XtIsManaged(jupform_w))
  690. X        XtUnmanageChild (jupform_w);
  691. X    else {
  692. X        XtManageChild (jupform_w);
  693. X        jm_set_buttons(jm_selecting);
  694. X    }
  695. X}
  696. X
  697. Xjm_ison()
  698. X{
  699. X    return (jupform_w && XtIsManaged(jupform_w));
  700. X}
  701. X
  702. X/* called by other menus as they want to hear from our buttons or not.
  703. X * the "on"s and "off"s stack - only really redo the buttons if it's the
  704. X * first on or the last off.
  705. X */
  706. Xvoid
  707. Xjm_selection_mode (whether)
  708. Xint whether;    /* whether setting up for plotting or for not plotting */
  709. X{
  710. X    jm_selecting += whether ? 1 : -1;
  711. X
  712. X    if (jupform_w && XtIsManaged(jupform_w))
  713. X        if (whether && jm_selecting == 1     /* first one to want on */
  714. X        || !whether && jm_selecting == 0 /* last one to want off */)
  715. X        jm_set_buttons (whether);
  716. X}
  717. X
  718. X/* called to recompute and fill in values for the jupiter menu.
  719. X * don't bother if it doesn't exist or is unmanaged now and we are not logging.
  720. X */
  721. Xvoid
  722. Xjm_update (np, how_much)
  723. XNow *np;
  724. Xint how_much;
  725. X{
  726. X    static char fmt[] = "%7.3f";
  727. X    MoonData moons[NM];
  728. X    double sIcml, sIIcml;
  729. X    int i;
  730. X
  731. X    if (!jupform_w)
  732. X        return;
  733. X    if (!XtIsManaged(jupform_w) && !any_ison() && !how_much)
  734. X        return;
  735. X
  736. X    /* compute jupiter info.
  737. X     */
  738. X    jupinfo (mjd, moons, &sIcml, &sIIcml);
  739. X
  740. X    f_double (cml_w[CMLI], fmt, sIcml);
  741. X    f_double (cml_w[CMLII], fmt, sIIcml);
  742. X
  743. X    for (i = 0; i < NM; i++) {
  744. X        f_double (j_w[i][X], fmt, moons[i].x);
  745. X        f_double (j_w[i][Y], fmt, moons[i].y);
  746. X        f_double (j_w[i][Z], fmt, moons[i].z);
  747. X    }
  748. X
  749. X    if (XtIsManaged(jupform_w)) {
  750. X        jm_draw_map (jda_w, moons, sIcml, sIIcml);
  751. X        timestamp (np, dt_w);
  752. X    }
  753. X}
  754. X
  755. X/* called to put up or remove the watch cursor.  */
  756. Xvoid
  757. Xjm_cursor (c)
  758. XCursor c;
  759. X{
  760. X    Window win;
  761. X
  762. X    if (jupform_w && (win = XtWindow(jupform_w))) {
  763. X        Display *dsp = XtDisplay(jupform_w);
  764. X        if (c)
  765. X        XDefineCursor (dsp, win, c);
  766. X        else
  767. X        XUndefineCursor (dsp, win);
  768. X    }
  769. X}
  770. X
  771. Xstatic void
  772. Xjm_create_form_w()
  773. X{
  774. X    Widget w;
  775. X    Widget frame_w, r_w, title_w, col_w;
  776. X    Widget f_w, fr_w;
  777. X    XmString str;
  778. X    Arg args[20];
  779. X    int n;
  780. X    int i;
  781. X
  782. X    /* create form */
  783. X    n = 0;
  784. X    XtSetArg (args[n], XmNautoUnmanage, False); n++;
  785. X    XtSetArg (args[n], XmNdefaultPosition, False); n++;
  786. X    XtSetArg (args[n], XmNresizePolicy, XmRESIZE_NONE); n++;
  787. X    jupform_w = XmCreateFormDialog (toplevel_w, "Jupiter", args, n);
  788. X
  789. X    /* set some stuff in the parent DialogShell.
  790. X     * setting XmNdialogTitle in the Form didn't work..
  791. X     */
  792. X    n = 0;
  793. X    XtSetArg (args[n], XmNtitle, "xephem Jupiter Table"); n++;
  794. X    XtSetValues (XtParent(jupform_w), args, n);
  795. X
  796. X    /* make top two title rows */
  797. X
  798. X    n = 0;
  799. X    XtSetArg (args[n], XmNtopAttachment, XmATTACH_FORM); n++;
  800. X    XtSetArg (args[n], XmNleftAttachment, XmATTACH_FORM); n++;
  801. X    XtSetArg (args[n], XmNrightAttachment, XmATTACH_FORM); n++;
  802. X    r_w = XmCreateLabel (jupform_w, "Heading", args, n);
  803. X    XtManageChild (r_w);
  804. X    set_xmstring (r_w, XmNlabelString, 
  805. X        "Central Meridian Longitude (degs):\n(GRS is at 30 degs in System II)");
  806. X
  807. X    /* make row for CMLs */
  808. X
  809. X    n = 0;
  810. X    XtSetArg (args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
  811. X    XtSetArg (args[n], XmNtopWidget, r_w); n++;
  812. X    XtSetArg (args[n], XmNleftAttachment, XmATTACH_FORM); n++;
  813. X    XtSetArg (args[n], XmNuserData, "Jupiter.CMLI"); n++;
  814. X    w = cml_w[CMLI] = XmCreatePushButton(jupform_w, "CMLI", args, n);
  815. X    XtAddCallback(w, XmNactivateCallback, jm_activate_cb, 0);
  816. X    XtManageChild (w);
  817. X
  818. X    n = 0;
  819. X    XtSetArg (args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
  820. X    XtSetArg (args[n], XmNtopWidget, r_w); n++;
  821. X    XtSetArg (args[n], XmNleftAttachment, XmATTACH_WIDGET); n++;
  822. X    XtSetArg (args[n], XmNleftWidget, w); n++;
  823. X    w = XmCreatePushButton (jupform_w, "CMLIL", args, n);
  824. X    XtManageChild (w);
  825. X    jm_set_a_button (w, False);
  826. X    set_xmstring (w, XmNlabelString, "(Sys I)");
  827. X
  828. X    n = 0;
  829. X    XtSetArg (args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
  830. X    XtSetArg (args[n], XmNtopWidget, r_w); n++;
  831. X    XtSetArg (args[n], XmNrightAttachment, XmATTACH_FORM); n++;
  832. X    w = XmCreatePushButton (jupform_w, "CMLIIL", args, n);
  833. X    XtManageChild (w);
  834. X    jm_set_a_button (w, False);
  835. X    set_xmstring (w, XmNlabelString, "(Sys II)");
  836. X
  837. X    n = 0;
  838. X    XtSetArg (args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
  839. X    XtSetArg (args[n], XmNtopWidget, r_w); n++;
  840. X    XtSetArg (args[n], XmNrightAttachment, XmATTACH_WIDGET); n++;
  841. X    XtSetArg (args[n], XmNrightWidget, w); n++;
  842. X    XtSetArg (args[n], XmNuserData, "Jupiter.CMLII"); n++;
  843. X    w = cml_w[CMLII] = XmCreatePushButton(jupform_w, "CMLII", args, n);
  844. X    XtAddCallback(w, XmNactivateCallback, jm_activate_cb, 0);
  845. X    XtManageChild (w);
  846. X
  847. X    /* make table title label */
  848. X
  849. X    n = 0;
  850. X    XtSetArg (args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
  851. X    XtSetArg (args[n], XmNtopWidget, w); n++;
  852. X    XtSetArg (args[n], XmNleftAttachment, XmATTACH_FORM); n++;
  853. X    XtSetArg (args[n], XmNrightAttachment, XmATTACH_FORM); n++;
  854. X    title_w = XmCreateLabel (jupform_w, "TableLabel", args, n);
  855. X    XtManageChild (title_w);
  856. X    set_xmstring (title_w, XmNlabelString,
  857. X                " \nMoon positions -- in Jupiter Radii");
  858. X
  859. X    /* make the moon table, one column at a time */
  860. X
  861. X    /* moon designator column */
  862. X
  863. X    n = 0;
  864. X    XtSetArg (args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
  865. X    XtSetArg (args[n], XmNtopWidget, title_w); n++;
  866. X    XtSetArg (args[n], XmNleftAttachment, XmATTACH_FORM); n++;
  867. X    XtSetArg (args[n], XmNentryAlignment, XmALIGNMENT_CENTER); n++;
  868. X    XtSetArg (args[n], XmNisAligned, True); n++;
  869. X    col_w = XmCreateRowColumn (jupform_w, "MoonDes", args, n);
  870. X    XtManageChild (col_w);
  871. X
  872. X        n = 0;
  873. X        w = XmCreatePushButton (col_w, " ", args, n);
  874. X        XtManageChild (w);
  875. X        jm_set_a_button (w, False);
  876. X
  877. X        for (i = 0; i < NM; i++) {
  878. X        n = 0;
  879. X        w = XmCreatePushButton (col_w, mnames[i].tag, args, n);
  880. X        XtManageChild (w);
  881. X        jm_set_a_button (w, False);
  882. X        }
  883. X
  884. X    /* moon name column */
  885. X
  886. X    n = 0;
  887. X    XtSetArg (args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
  888. X    XtSetArg (args[n], XmNtopWidget, title_w); n++;
  889. X    XtSetArg (args[n], XmNleftAttachment, XmATTACH_POSITION); n++;
  890. X    XtSetArg (args[n], XmNleftPosition, 10); n++;
  891. X    XtSetArg (args[n], XmNentryAlignment, XmALIGNMENT_BEGINNING); n++;
  892. X    XtSetArg (args[n], XmNisAligned, True); n++;
  893. X    col_w = XmCreateRowColumn (jupform_w, "MoonName", args, n);
  894. X    XtManageChild (col_w);
  895. X
  896. X        n = 0;
  897. X        w = XmCreatePushButton (col_w, " ", args, n);
  898. X        XtManageChild (w);
  899. X        jm_set_a_button (w, False);
  900. X
  901. X        for (i = 0; i < NM; i++) {
  902. X        n = 0;
  903. X        w = XmCreatePushButton (col_w, mnames[i].full, args, n);
  904. X        XtManageChild (w);
  905. X        jm_set_a_button (w, False);
  906. X        }
  907. X
  908. X    /* moon X column */
  909. X
  910. X    n = 0;
  911. X    XtSetArg (args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
  912. X    XtSetArg (args[n], XmNtopWidget, title_w); n++;
  913. X    XtSetArg (args[n], XmNleftAttachment, XmATTACH_POSITION); n++;
  914. X    XtSetArg (args[n], XmNleftPosition, 35); n++;
  915. X    XtSetArg (args[n], XmNentryAlignment, XmALIGNMENT_CENTER); n++;
  916. X    XtSetArg (args[n], XmNisAligned, True); n++;
  917. X    col_w = XmCreateRowColumn (jupform_w, "MoonXRC", args, n);
  918. X    XtManageChild (col_w);
  919. X
  920. X        n = 0;
  921. X        w = XmCreatePushButton (col_w, "MoonX", args, n);
  922. X        XtManageChild (w);
  923. X        jm_set_a_button (w, False);
  924. X        set_xmstring (w, XmNlabelString, "X (+E)");
  925. X
  926. X        for (i = 0; i < NM; i++) {
  927. X        char *sel;
  928. X        sel = XtMalloc (strlen(mnames[i].full) + 3); /* '.X\0' */
  929. X        (void) sprintf (sel, "%s.X", mnames[i].full);
  930. X        n = 0;
  931. X        XtSetArg (args[n], XmNuserData, sel); n++;
  932. X        w = j_w[i][X] = XmCreatePushButton(col_w, "MoonXPB", args, n);
  933. X        XtAddCallback(w, XmNactivateCallback, jm_activate_cb, 0);
  934. X        XtManageChild (w);
  935. X        }
  936. X
  937. X    /* moon Y column */
  938. X
  939. X    n = 0;
  940. X    XtSetArg (args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
  941. X    XtSetArg (args[n], XmNtopWidget, title_w); n++;
  942. X    XtSetArg (args[n], XmNleftAttachment, XmATTACH_POSITION); n++;
  943. X    XtSetArg (args[n], XmNleftPosition, 55); n++;
  944. X    XtSetArg (args[n], XmNentryAlignment, XmALIGNMENT_CENTER); n++;
  945. X    XtSetArg (args[n], XmNisAligned, True); n++;
  946. X    col_w = XmCreateRowColumn (jupform_w, "MoonYRC", args, n);
  947. X    XtManageChild (col_w);
  948. X
  949. X        n = 0;
  950. X        w = XmCreatePushButton (col_w, "MoonYLabel", args, n);
  951. X        XtManageChild (w);
  952. X        set_xmstring (w, XmNlabelString, "Y (+S)");
  953. X        jm_set_a_button (w, False);
  954. X
  955. X        for (i = 0; i < NM; i++) {
  956. X        char *sel;
  957. X        sel = XtMalloc (strlen(mnames[i].full) + 3); /* '.Y\0' */
  958. X        (void) sprintf (sel, "%s.Y", mnames[i].full);
  959. X        n = 0;
  960. X        XtSetArg (args[n], XmNuserData, sel); n++;
  961. X        w = j_w[i][Y] = XmCreatePushButton(col_w, "MoonYPB", args, n);
  962. X        XtAddCallback(w, XmNactivateCallback, jm_activate_cb, 0);
  963. X        XtManageChild (w);
  964. X        }
  965. X
  966. X    /* moon Z column */
  967. X
  968. X    n = 0;
  969. X    XtSetArg (args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
  970. X    XtSetArg (args[n], XmNtopWidget, title_w); n++;
  971. X    XtSetArg (args[n], XmNleftAttachment, XmATTACH_POSITION); n++;
  972. X    XtSetArg (args[n], XmNleftPosition, 75); n++;
  973. X    XtSetArg (args[n], XmNrightAttachment, XmATTACH_FORM); n++;
  974. X    XtSetArg (args[n], XmNentryAlignment, XmALIGNMENT_CENTER); n++;
  975. X    XtSetArg (args[n], XmNisAligned, True); n++;
  976. X    col_w = XmCreateRowColumn (jupform_w, "MoonZRC", args, n);
  977. X    XtManageChild (col_w);
  978. X
  979. X        n = 0;
  980. X        w = XmCreatePushButton (col_w, "MoonZ", args, n);
  981. X        XtManageChild (w);
  982. X        set_xmstring (w, XmNlabelString, "Z (+front)");
  983. X        jm_set_a_button (w, False);
  984. X
  985. X        for (i = 0; i < NM; i++) {
  986. X        char *sel;
  987. X        sel = XtMalloc (strlen(mnames[i].full) + 3); /* '.Z\0' */
  988. X        (void) sprintf (sel, "%s.Z", mnames[i].full);
  989. X        n = 0;
  990. X        XtSetArg (args[n], XmNuserData, sel); n++;
  991. X        w = j_w[i][Z] = XmCreatePushButton(col_w, "MoonZPB", args, n);
  992. X        XtAddCallback(w, XmNactivateCallback, jm_activate_cb, 0);
  993. X        XtManageChild (w);
  994. X        }
  995. X
  996. X    /* make a Form to hold the bottom controls */
  997. X
  998. X    n = 0;
  999. X    XtSetArg (args[n], XmNfractionBase, 15); n++;
  1000. X    XtSetArg (args[n], XmNbottomAttachment, XmATTACH_FORM); n++;
  1001. X    XtSetArg (args[n], XmNleftAttachment, XmATTACH_FORM); n++;
  1002. X    XtSetArg (args[n], XmNrightAttachment, XmATTACH_FORM); n++;
  1003. X    f_w = XmCreateForm (jupform_w, "CtlForm", args, n);
  1004. X    XtManageChild (f_w);
  1005. X
  1006. X        /* make the close button */
  1007. X
  1008. X        n = 0;
  1009. X        XtSetArg (args[n], XmNtopAttachment, XmATTACH_FORM); n++;
  1010. X        XtSetArg (args[n], XmNbottomAttachment, XmATTACH_FORM); n++;
  1011. X        XtSetArg (args[n], XmNleftAttachment, XmATTACH_POSITION); n++;
  1012. X        XtSetArg (args[n], XmNleftPosition, 1); n++;
  1013. X        XtSetArg (args[n], XmNrightAttachment, XmATTACH_POSITION); n++;
  1014. X        XtSetArg (args[n], XmNrightPosition, 4); n++;
  1015. X        w = XmCreatePushButton (f_w, "Close", args, n);
  1016. X        XtAddCallback (w, XmNactivateCallback, jm_close_cb, 0);
  1017. X        XtManageChild (w);
  1018. X
  1019. X        /* make the tags toggle button in a frame */
  1020. X
  1021. X        n = 0;
  1022. X        XtSetArg (args[n], XmNtopAttachment, XmATTACH_FORM); n++;
  1023. X        XtSetArg (args[n], XmNbottomAttachment, XmATTACH_FORM); n++;
  1024. X        XtSetArg (args[n], XmNleftAttachment, XmATTACH_POSITION); n++;
  1025. X        XtSetArg (args[n], XmNleftPosition, 6); n++;
  1026. X        XtSetArg (args[n], XmNrightAttachment, XmATTACH_POSITION); n++;
  1027. X        XtSetArg (args[n], XmNrightPosition, 9); n++;
  1028. X        fr_w = XmCreateFrame (f_w, "TagsFr", args, n);
  1029. X        XtManageChild (fr_w);
  1030. X        n = 0;
  1031. X        w = XmCreateToggleButton (fr_w, "Tags", args, n);
  1032. X        XtAddCallback (w, XmNvalueChangedCallback, jm_tags_cb, 0);
  1033. X        XtManageChild (w);
  1034. X        j_tags = XmToggleButtonGetState(w);
  1035. X
  1036. X        /* "big dots" toggle button in a frame */
  1037. X
  1038. X        n = 0;
  1039. X        XtSetArg (args[n], XmNtopAttachment, XmATTACH_FORM); n++;
  1040. X        XtSetArg (args[n], XmNbottomAttachment, XmATTACH_FORM); n++;
  1041. X        XtSetArg (args[n], XmNleftAttachment, XmATTACH_POSITION); n++;
  1042. X        XtSetArg (args[n], XmNleftPosition, 11); n++;
  1043. X        XtSetArg (args[n], XmNrightAttachment, XmATTACH_POSITION); n++;
  1044. X        XtSetArg (args[n], XmNrightPosition, 14); n++;
  1045. X        fr_w = XmCreateFrame(f_w,"BigDotsFr",args,n);
  1046. X        XtManageChild (fr_w);
  1047. X        str = XmStringCreate("Big dots", XmSTRING_DEFAULT_CHARSET);
  1048. X        n = 0;
  1049. X        XtSetArg (args[n], XmNlabelString, str); n++;
  1050. X        w = XmCreateToggleButton(fr_w,"BigDots",args,n);
  1051. X        XtAddCallback(w, XmNvalueChangedCallback, jm_bigd_cb, 0);
  1052. X        XtManageChild (w);
  1053. X        XmStringFree (str);
  1054. X        bigdots = XmToggleButtonGetState(w);
  1055. X
  1056. X    /* make the date/time stamp label */
  1057. X
  1058. X    n = 0;
  1059. X    XtSetArg (args[n], XmNbottomAttachment, XmATTACH_WIDGET); n++;
  1060. X    XtSetArg (args[n], XmNbottomWidget, f_w); n++;
  1061. X    XtSetArg (args[n], XmNleftAttachment, XmATTACH_FORM); n++;
  1062. X    XtSetArg (args[n], XmNrightAttachment, XmATTACH_FORM); n++;
  1063. X    dt_w = XmCreateLabel (jupform_w, "DateStamp", args, n);
  1064. X    timestamp (mm_get_now(), dt_w);    /* establishes size */
  1065. X    XtManageChild (dt_w);
  1066. X
  1067. X    /* make the scale widget
  1068. X     * attach both top and bottom so it's the one to follow resizing.
  1069. X     */
  1070. X
  1071. X    n = 0;
  1072. X    XtSetArg (args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
  1073. X    XtSetArg (args[n], XmNtopWidget, col_w); n++;
  1074. X    XtSetArg (args[n], XmNbottomAttachment, XmATTACH_WIDGET); n++;
  1075. X    XtSetArg (args[n], XmNbottomWidget, dt_w); n++;
  1076. X    XtSetArg (args[n], XmNleftAttachment, XmATTACH_FORM); n++;
  1077. X    XtSetArg (args[n], XmNmaximum, 100); n++;
  1078. X    XtSetArg (args[n], XmNminimum, 0); n++;
  1079. X    XtSetArg (args[n], XmNscaleMultiple, 10); n++;
  1080. X    XtSetArg (args[n], XmNorientation, XmVERTICAL); n++;
  1081. X    XtSetArg (args[n], XmNprocessingDirection, XmMAX_ON_TOP); n++;
  1082. X    scale_w = XmCreateScale (jupform_w, "Scale", args, n);
  1083. X    XtAddCallback (scale_w, XmNdragCallback, jm_scale_cb, 0);
  1084. X    XtAddCallback (scale_w, XmNvalueChangedCallback, jm_scale_cb, 0);
  1085. X    XtManageChild (scale_w);
  1086. X
  1087. X    /* make a frame for the drawing area.
  1088. X     * attach both top and bottom so it's the one to follow resizing.
  1089. X     */
  1090. X
  1091. X    n = 0;
  1092. X    XtSetArg (args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
  1093. X    XtSetArg (args[n], XmNtopWidget, col_w); n++;
  1094. X    XtSetArg (args[n], XmNbottomAttachment, XmATTACH_WIDGET); n++;
  1095. X    XtSetArg (args[n], XmNbottomWidget, dt_w); n++;
  1096. X    XtSetArg (args[n], XmNleftAttachment, XmATTACH_WIDGET); n++;
  1097. X    XtSetArg (args[n], XmNleftWidget, scale_w); n++;
  1098. X    XtSetArg (args[n], XmNrightAttachment, XmATTACH_FORM); n++;
  1099. X    XtSetArg (args[n], XmNshadowType, XmSHADOW_ETCHED_OUT); n++;
  1100. X    frame_w = XmCreateFrame (jupform_w, "DAFrame", args, n);
  1101. X    XtManageChild (frame_w);
  1102. X
  1103. X        /* make a drawing area for drawing the little map */
  1104. X
  1105. X        n = 0;
  1106. X        jda_w = XmCreateDrawingArea (frame_w, "Map", args, n);
  1107. X        XtAddCallback (jda_w, XmNexposeCallback, jm_da_exp_cb, 0);
  1108. X        XtManageChild (jda_w);
  1109. X}
  1110. X
  1111. X/* go through all the buttons pickable for plotting and set whether they
  1112. X * should appear to look like buttons or just flat labels.
  1113. X */
  1114. Xstatic void
  1115. Xjm_set_buttons (whether)
  1116. Xint whether;    /* whether setting up for plotting or for not plotting */
  1117. X{
  1118. X    int i;
  1119. X
  1120. X    for (i = 0; i < NM; i++) {
  1121. X        jm_set_a_button (j_w[i][X], whether);
  1122. X        jm_set_a_button (j_w[i][Y], whether);
  1123. X        jm_set_a_button (j_w[i][Z], whether);
  1124. X    }
  1125. X
  1126. X    jm_set_a_button (cml_w[CMLI], whether);
  1127. X    jm_set_a_button (cml_w[CMLII], whether);
  1128. X}
  1129. X
  1130. X/* set whether the given button looks like a label.
  1131. X */
  1132. Xstatic void
  1133. Xjm_set_a_button(pbw, whether)
  1134. XWidget pbw;
  1135. Xint whether;
  1136. X{
  1137. X    static Arg look_like_button[] = {
  1138. X        {XmNtopShadowColor, (XtArgVal) 0},
  1139. X        {XmNbottomShadowColor, (XtArgVal) 0},
  1140. X        {XmNfillOnArm, (XtArgVal) True},
  1141. X    };
  1142. X    static Arg look_like_label[] = {
  1143. X        {XmNtopShadowColor, (XtArgVal) 0},
  1144. X        {XmNbottomShadowColor, (XtArgVal) 0},
  1145. X        {XmNfillOnArm, (XtArgVal) False},
  1146. X    };
  1147. X    static int called;
  1148. X    Arg *ap;
  1149. X    int na;
  1150. X
  1151. X    if (!called) {
  1152. X        /* get baseline label and shadow appearances.
  1153. X         */
  1154. X        Pixel topshad, botshad, bgcol;
  1155. X        Arg args[20];
  1156. X        Widget tmpw;
  1157. X        int n;
  1158. X
  1159. X        n = 0;
  1160. X        tmpw = XmCreatePushButton (jupform_w, "tmp", args, n);
  1161. X
  1162. X        n = 0;
  1163. X        XtSetArg (args[n], XmNtopShadowColor, &topshad); n++;
  1164. X        XtSetArg (args[n], XmNbottomShadowColor, &botshad); n++;
  1165. X        XtSetArg (args[n], XmNbackground, &bgcol); n++;
  1166. X        XtGetValues (tmpw, args, n);
  1167. X
  1168. X        look_like_button[0].value = topshad;
  1169. X        look_like_button[1].value = botshad;
  1170. X        look_like_label[0].value = bgcol;
  1171. X        look_like_label[1].value = bgcol;
  1172. X
  1173. X        XtDestroyWidget (tmpw);
  1174. X         
  1175. X        called = 1;
  1176. X    }
  1177. X
  1178. X    if (whether) {
  1179. X        ap = look_like_button;
  1180. X        na = XtNumber(look_like_button);
  1181. X    } else {
  1182. X        ap = look_like_label;
  1183. X        na = XtNumber(look_like_label);
  1184. X    }
  1185. X
  1186. X    XtSetValues (pbw, ap, na);
  1187. X}
  1188. X
  1189. X/* callback from the big dots toggle button
  1190. X * TODO: really shouldn't get present time, just redo dots in same location.
  1191. X */
  1192. X/* ARGSUSED */
  1193. Xstatic void
  1194. Xjm_bigd_cb (w, client, call)
  1195. XWidget w;
  1196. XXtPointer client;
  1197. XXtPointer call;
  1198. X{
  1199. X    bigdots = XmToggleButtonGetState(w);
  1200. X    jm_update (mm_get_now(), 1);
  1201. X}
  1202. X
  1203. X/* callback from the tags toggle button
  1204. X * TODO: really shouldn't get present time, just redo dots in same location.
  1205. X */
  1206. X/* ARGSUSED */
  1207. Xstatic void
  1208. Xjm_tags_cb (w, client, call)
  1209. XWidget w;
  1210. XXtPointer client;
  1211. XXtPointer call;
  1212. X{
  1213. X    j_tags = XmToggleButtonGetState(w);
  1214. X    jm_update (mm_get_now(), 1);
  1215. X}
  1216. X
  1217. X/* callback from the scale.
  1218. X * TODO: really shouldn't get present time, just redo dots in same location.
  1219. X */
  1220. X/* ARGSUSED */
  1221. Xstatic void
  1222. Xjm_scale_cb (w, client, call)
  1223. XWidget w;
  1224. XXtPointer client;
  1225. XXtPointer call;
  1226. X{
  1227. X    jm_update (mm_get_now(), 1);
  1228. X}
  1229. X
  1230. X/* callback from any of the data menu buttons being activated.
  1231. X */
  1232. X/* ARGSUSED */
  1233. Xstatic void
  1234. Xjm_activate_cb (w, client, call)
  1235. XWidget w;
  1236. XXtPointer client;
  1237. XXtPointer call;
  1238. X{
  1239. X    if (jm_selecting) {
  1240. X        char *name;
  1241. X        get_something (w, XmNuserData, (char *)&name);
  1242. X        register_selection (name);
  1243. X    }
  1244. X}
  1245. X
  1246. X/* callback from the Close button
  1247. X */
  1248. X/* ARGSUSED */
  1249. Xstatic void
  1250. Xjm_close_cb (w, client, call)
  1251. XWidget w;
  1252. XXtPointer client;
  1253. XXtPointer call;
  1254. X{
  1255. X    XtUnmanageChild (jupform_w);
  1256. X}
  1257. X
  1258. X/* callback from either expose of the drawing area.
  1259. X */
  1260. X/* ARGSUSED */
  1261. Xstatic void
  1262. Xjm_da_exp_cb (w, client, call)
  1263. XWidget w;
  1264. XXtPointer client;
  1265. XXtPointer call;
  1266. X{
  1267. X    XmDrawingAreaCallbackStruct *c = (XmDrawingAreaCallbackStruct *)call;
  1268. X
  1269. X    /* filter out a few oddball cases */
  1270. X    switch (c->reason) {
  1271. X    case XmCR_EXPOSE: {
  1272. X        /* turn off gravity so we get expose events for either shrink or
  1273. X         * expand.
  1274. X         */
  1275. X        static before;
  1276. X        XExposeEvent *e = &c->event->xexpose;
  1277. X
  1278. X        if (!before) {
  1279. X        XSetWindowAttributes swa;
  1280. X        swa.bit_gravity = ForgetGravity;
  1281. X        XChangeWindowAttributes (e->display, e->window, 
  1282. X                                CWBitGravity, &swa);
  1283. X        before = 1;
  1284. X        }
  1285. X        /* wait for the last in the series */
  1286. X        if (e->count != 0)
  1287. X        return;
  1288. X        break;
  1289. X        }
  1290. X    default:
  1291. X        printf ("Unexpected jupform_w event. type=%d\n", c->reason);
  1292. X        exit(1);
  1293. X    }
  1294. X
  1295. X    jm_update (mm_get_now(), 1);
  1296. X}
  1297. X
  1298. X/* given the loc of the moons, draw a nifty little picture.
  1299. X * scale of the locations is in terms of jupiter radii == 1.
  1300. X */
  1301. X/* ARGSUSED */
  1302. Xstatic void
  1303. Xjm_draw_map (w, moons, sIcml, sIIcml)
  1304. XWidget w;
  1305. XMoonData moons[NM];
  1306. Xdouble sIcml, sIIcml;
  1307. X{
  1308. X    static GC j_fgc, j_bgc, j_xgc;
  1309. X    static XFontStruct *j_fs;
  1310. X    static last_nx, last_ny;
  1311. X    static int cw, ch;
  1312. X    static Pixmap pm;
  1313. X    Display *dsp = XtDisplay(w);
  1314. X    Window win = XtWindow(w);
  1315. X    Window root;
  1316. X    double scale;
  1317. X    int sv;
  1318. X    char c;
  1319. X    int x, y;
  1320. X    unsigned int nx, ny, bw, d;
  1321. X    int i;
  1322. X#define    NORM    27.0    /* max callisto orbit radius; used to normalize */
  1323. X#define    MAPSCALE(v)    ((v)*((int)nx)/NORM/2*scale)
  1324. X#define    XCORD(x)    ((int)(((int)nx)/2.0 + MAPSCALE(x) + 0.5))
  1325. X#define    YCORD(y)    ((int)(((int)ny)/2.0 - MAPSCALE(y) + 0.5))
  1326. X
  1327. X    if (!j_fgc) {
  1328. X        XGCValues gcv;
  1329. X        unsigned int gcm;
  1330. X        Pixel fg, bg;
  1331. X
  1332. X        gcm = GCForeground;
  1333. X        get_something (w, XmNforeground, (char *)&fg);
  1334. X        gcv.foreground = fg;
  1335. X        j_fgc = XCreateGC (dsp, win, gcm, &gcv);
  1336. X        j_fs = XQueryFont (dsp, XGContextFromGC (j_fgc));
  1337. X        cw = j_fs->max_bounds.width;
  1338. X        ch = j_fs->max_bounds.ascent + j_fs->max_bounds.descent;
  1339. X
  1340. X        gcm = GCForeground;
  1341. X        get_something (w, XmNbackground, (char *)&bg);
  1342. X        gcv.foreground = bg;
  1343. X        j_bgc = XCreateGC (dsp, win, gcm, &gcv);
  1344. X
  1345. X        gcm = GCForeground | GCFunction;
  1346. X        gcv.foreground = fg ^ bg;
  1347. X        gcv.function = GXxor;
  1348. X        j_xgc = XCreateGC (dsp, win, gcm, &gcv);
  1349. X    }
  1350. X
  1351. X    XmScaleGetValue (scale_w, &sv);
  1352. X    scale = pow(MAXSCALE, sv/100.0);
  1353. X
  1354. X    XGetGeometry(dsp, win, &root, &x, &y, &nx, &ny, &bw, &d);
  1355. X    if (!pm || nx != last_nx || ny != last_ny) {
  1356. X        if (pm)
  1357. X        XFreePixmap (dsp, pm);
  1358. X        pm = XCreatePixmap (dsp, win, nx, ny, d);
  1359. X        last_nx = nx;
  1360. X        last_ny = ny;
  1361. X    }
  1362. X
  1363. X    XFillRectangle (dsp, pm, j_bgc, 0, 0, nx, ny);
  1364. X
  1365. X    c = 'E'; XDrawString(dsp, pm, j_fgc, nx-cw-1, ny/2-2, &c, 1);
  1366. X    c = 'S'; XDrawString(dsp, pm, j_fgc, (nx-cw)/2-1, j_fs->ascent, &c, 1);
  1367. X
  1368. X    /* draw Jupiter of unit radius */
  1369. X    XFillArc (dsp, pm, j_fgc, XCORD(-1), YCORD(1), 2*(int)MAPSCALE(1),
  1370. X                        2*(int)MAPSCALE(1), 0, 360*64);
  1371. X
  1372. X    /* draw each moon that is visible.
  1373. X     */
  1374. X    for (i = 0; i < NM; i++) {
  1375. X        double mx = moons[i].x;
  1376. X        double my = moons[i].y;
  1377. X        double mz = moons[i].z;
  1378. X        int outside = mx*mx + my*my > 1.0;
  1379. X        int infront = mz > 0.0;
  1380. X
  1381. X        if (!outside && !infront)
  1382. X        continue;    /* behind jupiter */
  1383. X
  1384. X        x = XCORD(mx);
  1385. X        y = YCORD(my);
  1386. X        XDrawPoint (dsp, pm, j_xgc, x, y);
  1387. X        if (bigdots) {
  1388. X        XDrawPoint(dsp, pm, j_xgc, x+1, y);
  1389. X        XDrawPoint(dsp, pm, j_xgc, x,   y+1);
  1390. X        XDrawPoint(dsp, pm, j_xgc, x+1, y+1);
  1391. X        }
  1392. X        if (j_tags)
  1393. X        XDrawString(dsp, pm, j_xgc, x-cw/2, y+2*ch,
  1394. X                    mnames[i].tag, strlen(mnames[i].tag));
  1395. X    }
  1396. X
  1397. X    XCopyArea (dsp, pm, win, j_fgc, 0, 0, nx, ny, 0, 0);
  1398. X}
  1399. X
  1400. X
  1401. X#define    dsin(x)    sin(degrad(x))
  1402. X#define    dcos(x)    cos(degrad(x))
  1403. X
  1404. X/* given a modified julian date (ie, days since Jan .5 1900), d, return x, y, z
  1405. X *   location of each Galilean moon as a multiple of Jupiter's radius. on this
  1406. X *   scale, Callisto is never more than 26.5593. +x is easterly, +y is
  1407. X *   southerly, +z is towards earth. x and z are relative to the equator
  1408. X *   of Jupiter; y is further corrected for earth's position above or below
  1409. X *   this plane. also, return the system I and II central meridian longitude,
  1410. X *   in degress, relative to the true disk of jupiter and corrected for light
  1411. X *   travel time.
  1412. X * from "Astronomical Formulae for Calculators", 2nd ed, by Jean Meeus,
  1413. X *   Willmann-Bell, Richmond, Va., U.S.A. (c) 1982, chapters 35 and 36.
  1414. X */
  1415. Xstatic void
  1416. Xjupinfo (d, moons, sIcml, sIIcml)
  1417. Xdouble d;
  1418. XMoonData moons[NM];    /* Io, Europa, Ganymede, Callisto */
  1419. Xdouble *sIcml, *sIIcml;
  1420. X{
  1421. X    double A, B, Del, J, K, M, N, R, V;
  1422. X    double cor_u1, cor_u2, cor_u3, cor_u4;
  1423. X    double solc, tmp, G, H, psi, r, r1, r2, r3, r4;
  1424. X    double u1, u2, u3, u4;
  1425. X    double lam, Ds;
  1426. X    double z1, z2, z3,  z4;
  1427. X    double De, dsinDe;
  1428. X
  1429. X    V = 134.63 + 0.00111587 * d;
  1430. X
  1431. X    M = (358.47583 + 0.98560003*d);
  1432. X    N = (225.32833 + 0.0830853*d) + 0.33 * dsin (V);
  1433. X
  1434. X    J = 221.647 + 0.9025179*d - 0.33 * dsin(V);;
  1435. X
  1436. X    A = 1.916*dsin(M) + 0.02*dsin(2*M);
  1437. X    B = 5.552*dsin(N) + 0.167*dsin(2*N);
  1438. X    K = (J+A-B);
  1439. X    R = 1.00014 - 0.01672 * dcos(M) - 0.00014 * dcos(2*M);
  1440. X    r = 5.20867 - 0.25192 * dcos(N) - 0.00610 * dcos(2*N);
  1441. X    Del = sqrt (R*R + r*r - 2*R*r*dcos(K));
  1442. X    psi = raddeg (asin (R/Del*dsin(K)));
  1443. X
  1444. X    solc = (d - Del/173.);    /* speed of light correction */
  1445. X    tmp = psi - B;
  1446. X
  1447. X    u1 = 84.5506 + 203.4058630 * solc + tmp;
  1448. X    u2 = 41.5015 + 101.2916323 * solc + tmp;
  1449. X    u3 = 109.9770 + 50.2345169 * solc + tmp;
  1450. X    u4 = 176.3586 + 21.4879802 * solc + tmp;
  1451. X
  1452. X    G = 187.3 + 50.310674 * solc;
  1453. X    H = 311.1 + 21.569229 * solc;
  1454. X      
  1455. X    cor_u1 =  0.472 * dsin (2*(u1-u2));
  1456. X    cor_u2 =  1.073 * dsin (2*(u2-u3));
  1457. X    cor_u3 =  0.174 * dsin (G);
  1458. X    cor_u4 =  0.845 * dsin (H);
  1459. X      
  1460. X    r1 = 5.9061 - 0.0244 * dcos (2*(u1-u2));
  1461. X    r2 = 9.3972 - 0.0889 * dcos (2*(u2-u3));
  1462. X    r3 = 14.9894 - 0.0227 * dcos (G);
  1463. X    r4 = 26.3649 - 0.1944 * dcos (H);
  1464. X
  1465. X    moons[0].x = -r1 * dsin (u1+cor_u1);
  1466. X    moons[1].x = -r2 * dsin (u2+cor_u2);
  1467. X    moons[2].x = -r3 * dsin (u3+cor_u3);
  1468. X    moons[3].x = -r4 * dsin (u4+cor_u4);
  1469. X
  1470. X    lam = 238.05 + 0.083091*d + 0.33*dsin(V) + B;
  1471. X    Ds = 3.07*dsin(lam + 44.5);
  1472. X    De = Ds - 2.15*dsin(psi)*dcos(lam+24.)
  1473. X        - 1.31*(r-Del)/Del*dsin(lam-99.4);
  1474. X    dsinDe = dsin(De);
  1475. X
  1476. X    z1 = r1 * dcos(u1+cor_u1);
  1477. X    z2 = r2 * dcos(u2+cor_u2);
  1478. X    z3 = r3 * dcos(u3+cor_u3);
  1479. X    z4 = r4 * dcos(u4+cor_u4);
  1480. X
  1481. X    moons[0].y = z1*dsinDe;
  1482. X    moons[1].y = z2*dsinDe;
  1483. X    moons[2].y = z3*dsinDe;
  1484. X    moons[3].y = z4*dsinDe;
  1485. X
  1486. X    moons[0].z = z1;
  1487. X    moons[1].z = z2;
  1488. X    moons[2].z = z3;
  1489. X    moons[3].z = z4;
  1490. X
  1491. X    *sIcml  = 268.28 + 877.8169088*(d - Del/173) + psi - B;
  1492. X    range (sIcml, 360.0);
  1493. X    *sIIcml = 290.28 + 870.1869088*(d - Del/173) + psi - B;
  1494. X    range (sIIcml, 360.0);
  1495. X}
  1496. END_OF_FILE
  1497.   if test 26718 -ne `wc -c <'jupmenu.c'`; then
  1498.     echo shar: \"'jupmenu.c'\" unpacked with wrong size!
  1499.   fi
  1500.   # end of 'jupmenu.c'
  1501. fi
  1502. if test -f 'skyviewmenu.c.2' -a "${1}" != "-c" ; then 
  1503.   echo shar: Will not clobber existing file \"'skyviewmenu.c.2'\"
  1504. else
  1505.   echo shar: Extracting \"'skyviewmenu.c.2'\" \(26155 characters\)
  1506.   sed "s/^X//" >'skyviewmenu.c.2' <<'END_OF_FILE'
  1507. X    XtSetArg (args[n], XmNorientation, XmHORIZONTAL); n++;
  1508. X    XtSetArg (args[n], XmNscaleMultiple, 1); n++;
  1509. X    XtSetArg (args[n], XmNshowValue, True); n++;
  1510. X    azra_w = XmCreateScale (svform_w, "AzRAScale", args, n);
  1511. X    XtAddCallback (azra_w, XmNvalueChangedCallback, sv_changed_cb, NULL);
  1512. X    XtManageChild (azra_w);
  1513. X
  1514. X    /* make the left scale */
  1515. X
  1516. X    str = XmStringCreate ("FOV", XmSTRING_DEFAULT_CHARSET);
  1517. X    n = 0;
  1518. X    XtSetArg (args[n], XmNtopAttachment, XmATTACH_FORM); n++;
  1519. X    XtSetArg (args[n], XmNleftAttachment, XmATTACH_WIDGET); n++;
  1520. X    XtSetArg (args[n], XmNleftWidget, sep_w); n++;
  1521. X    XtSetArg (args[n], XmNbottomAttachment, XmATTACH_WIDGET); n++;
  1522. X    XtSetArg (args[n], XmNbottomWidget, azra_w); n++;
  1523. X    XtSetArg (args[n], XmNorientation, XmVERTICAL); n++;
  1524. X    XtSetArg (args[n], XmNminimum, 1); n++;
  1525. X    XtSetArg (args[n], XmNmaximum, 180); n++;
  1526. X    XtSetArg (args[n], XmNprocessingDirection, XmMAX_ON_BOTTOM); n++;
  1527. X    XtSetArg (args[n], XmNscaleMultiple, 1); n++;
  1528. X    XtSetArg (args[n], XmNshowValue, True); n++;
  1529. X    XtSetArg (args[n], XmNtitleString, str); n++;
  1530. X    fov_w = XmCreateScale (svform_w, "FOVScale", args, n);
  1531. X    XtAddCallback (fov_w, XmNvalueChangedCallback, sv_changed_cb, NULL);
  1532. X    XtManageChild (fov_w);
  1533. X    XmStringFree (str);
  1534. X
  1535. X    /* make the right scale */
  1536. X
  1537. X    n = 0;
  1538. X    XtSetArg (args[n], XmNtopAttachment, XmATTACH_FORM); n++;
  1539. X    XtSetArg (args[n], XmNrightAttachment, XmATTACH_FORM); n++;
  1540. X    XtSetArg (args[n], XmNbottomAttachment, XmATTACH_WIDGET); n++;
  1541. X    XtSetArg (args[n], XmNbottomWidget, azra_w); n++;
  1542. X    XtSetArg (args[n], XmNorientation, XmVERTICAL); n++;
  1543. X    XtSetArg (args[n], XmNprocessingDirection, XmMAX_ON_TOP); n++;
  1544. X    XtSetArg (args[n], XmNscaleMultiple, 1); n++;
  1545. X    XtSetArg (args[n], XmNshowValue, True); n++;
  1546. X    altdec_w = XmCreateScale (svform_w, "AltDecScale", args, n);
  1547. X    XtAddCallback (altdec_w, XmNvalueChangedCallback, sv_changed_cb, NULL);
  1548. X    XtManageChild (altdec_w);
  1549. X
  1550. X    /* make ra/dec tracking labels just above the bottom scale on either
  1551. X     * side.
  1552. X     */
  1553. X
  1554. X    n = 0;
  1555. X    XtSetArg (args[n], XmNleftAttachment, XmATTACH_WIDGET); n++;
  1556. X    XtSetArg (args[n], XmNleftWidget, fov_w); n++;
  1557. X    XtSetArg (args[n], XmNbottomAttachment, XmATTACH_WIDGET); n++;
  1558. X    XtSetArg (args[n], XmNbottomWidget, azra_w); n++;
  1559. X    XtSetArg (args[n], XmNalignment, XmALIGNMENT_BEGINNING); n++;
  1560. X    tra_w = XmCreateLabel (svform_w, "TRA", args, n);
  1561. X    set_xmstring (tra_w, XmNlabelString, " ");
  1562. X    XtManageChild(tra_w);
  1563. X
  1564. X    n = 0;
  1565. X    XtSetArg (args[n], XmNrightAttachment, XmATTACH_WIDGET); n++;
  1566. X    XtSetArg (args[n], XmNrightWidget, altdec_w); n++;
  1567. X    XtSetArg (args[n], XmNbottomAttachment, XmATTACH_WIDGET); n++;
  1568. X    XtSetArg (args[n], XmNbottomWidget, azra_w); n++;
  1569. X    XtSetArg (args[n], XmNalignment, XmALIGNMENT_END); n++;
  1570. X    tdec_w = XmCreateLabel (svform_w, "TDec", args, n);
  1571. X    set_xmstring (tdec_w, XmNlabelString, " ");
  1572. X    XtManageChild(tdec_w);
  1573. X
  1574. X    /* make alt/az tracking labels on top on either side */
  1575. X
  1576. X    n = 0;
  1577. X    XtSetArg (args[n], XmNleftAttachment, XmATTACH_WIDGET); n++;
  1578. X    XtSetArg (args[n], XmNleftWidget, fov_w); n++;
  1579. X    XtSetArg (args[n], XmNtopAttachment, XmATTACH_FORM); n++;
  1580. X    XtSetArg (args[n], XmNalignment, XmALIGNMENT_BEGINNING); n++;
  1581. X    talt_w = XmCreateLabel (svform_w, "TAlt", args, n);
  1582. X    set_xmstring (talt_w, XmNlabelString, " ");
  1583. X    XtManageChild(talt_w);
  1584. X
  1585. X    n = 0;
  1586. X    XtSetArg (args[n], XmNrightAttachment, XmATTACH_WIDGET); n++;
  1587. X    XtSetArg (args[n], XmNrightWidget, altdec_w); n++;
  1588. X    XtSetArg (args[n], XmNtopAttachment, XmATTACH_FORM); n++;
  1589. X    XtSetArg (args[n], XmNalignment, XmALIGNMENT_END); n++;
  1590. X    taz_w = XmCreateLabel (svform_w, "TAz", args, n);
  1591. X    set_xmstring (taz_w, XmNlabelString, " ");
  1592. X    XtManageChild(taz_w);
  1593. X
  1594. X    /* make a drawing area inside the sliders for drawing the sky */
  1595. X
  1596. X    n = 0;
  1597. X    XtSetArg (args[n], XmNtopAttachment, XmATTACH_FORM); n++;
  1598. X    XtSetArg (args[n], XmNbottomAttachment, XmATTACH_WIDGET); n++;
  1599. X    XtSetArg (args[n], XmNbottomWidget, azra_w); n++;
  1600. X    XtSetArg (args[n], XmNleftAttachment, XmATTACH_WIDGET); n++;
  1601. X    XtSetArg (args[n], XmNleftWidget, fov_w); n++;
  1602. X    XtSetArg (args[n], XmNrightAttachment, XmATTACH_WIDGET); n++;
  1603. X    XtSetArg (args[n], XmNrightWidget, altdec_w); n++;
  1604. X    svda_w = XmCreateDrawingArea (svform_w, "Map", args, n);
  1605. X    XtAddCallback (svda_w, XmNexposeCallback, sv_da_exp_cb, 0);
  1606. X    XtAddCallback (svda_w, XmNinputCallback, sv_da_input_cb, 0);
  1607. X    mask = Button1MotionMask | ButtonPressMask | ButtonReleaseMask
  1608. X                           | PointerMotionHintMask,
  1609. X    XtAddEventHandler (svda_w, mask, False, sv_da_motion_cb,0);
  1610. X    XtManageChild (svda_w);
  1611. X
  1612. X    /* create the filter dialog.
  1613. X     * it's not managed yet, but its state info is used right off.
  1614. X     */
  1615. X    svf_create();
  1616. X
  1617. X    /* create the popup */
  1618. X    sv_create_popup();
  1619. X
  1620. X    sv_set_view();
  1621. X    sv_set_scales();
  1622. X}
  1623. X
  1624. Xstatic void
  1625. Xsv_create_find (parent)
  1626. XWidget parent;
  1627. X{
  1628. X    Arg args[20];
  1629. X    Widget mb_w, menu_w, p_w;
  1630. X    Widget w;
  1631. X    int n;
  1632. X    int i;
  1633. X
  1634. X    /* create menu bar for the cascade button */
  1635. X
  1636. X    n = 0;
  1637. X    XtSetArg (args[n], XmNrowColumnType, XmMENU_BAR); n++;
  1638. X    mb_w = XmCreateRowColumn (parent, "PointMB", args, n);
  1639. X    XtManageChild (mb_w);
  1640. X
  1641. X    /* create pulldown managed by the cascade button */
  1642. X    n = 0;
  1643. X    menu_w = XmCreatePulldownMenu (parent, "PointPD", args, n);
  1644. X
  1645. X        /* create the pushbuttons forming the cascade menu.
  1646. X         * go ahead and fill in and manage the planet names now.
  1647. X         * we do the user objects just as we are cascading.
  1648. X         */
  1649. X        for (i = 0; i < NOBJ; i++) {
  1650. X        n = 0;
  1651. X        w = XmCreatePushButton (menu_w, "PointPB", args, n);
  1652. X        XtAddCallback (w, XmNactivateCallback, sv_find_cb,
  1653. X                                (XtPointer)i);
  1654. X        if (i >= MERCURY && i <= MOON) {
  1655. X            Obj *op = db_basic (i);
  1656. X            set_xmstring (w, XmNlabelString, op->o_name);
  1657. X            XtManageChild (w);
  1658. X        } else if (i == OBJX)
  1659. X            find_w[0] = w;
  1660. X        else if (i == OBJY)
  1661. X            find_w[1] = w;
  1662. X        }
  1663. X
  1664. X    n = 0;
  1665. X    XtSetArg (args[n], XmNsubMenuId, menu_w); n++;
  1666. X    XtSetArg (args[n], XmNmarginHeight, 0); n++;
  1667. X    XtSetArg (args[n], XmNalignment, XmALIGNMENT_CENTER); n++;
  1668. X    p_w = XmCreateCascadeButton (mb_w, "PointCB", args, n);
  1669. X    set_xmstring (p_w, XmNlabelString, "Locate...");
  1670. X    XtAddCallback (p_w, XmNcascadingCallback, sv_finding_cb, 0);
  1671. X    XtManageChild (p_w);
  1672. X}
  1673. X
  1674. X/* callback from the main Close button.
  1675. X */
  1676. X/* ARGSUSED */
  1677. Xstatic void
  1678. Xsv_close_cb (w, client, call)
  1679. XWidget w;
  1680. XXtPointer client;
  1681. XXtPointer call;
  1682. X{
  1683. X    XtUnmanageChild (svform_w);
  1684. X    svf_unmanage ();
  1685. X    if (sv_pm) {
  1686. X        XFreePixmap (XtDisplay(svda_w), sv_pm);
  1687. X        sv_pm = (Pixmap) NULL;
  1688. X    }
  1689. X}
  1690. X
  1691. X/* callback from the Help button.
  1692. X */
  1693. X/* ARGSUSED */
  1694. Xstatic void
  1695. Xsv_help_cb (w, client, call)
  1696. XWidget w;
  1697. XXtPointer client;
  1698. XXtPointer call;
  1699. X{
  1700. X    static char *msg[] = {
  1701. X"This displays all database objects currently in memory onto the sky. The view",
  1702. X"may be Alt/Az or RA/Dec. The three sliders adjust the field of fov, the",
  1703. X"azimuth (or RA), and the altitude (or Dec). Objects may be filtered out by",
  1704. X"type and magnitude."
  1705. X};
  1706. X
  1707. X    hlp_dialog ("Sky View", msg, sizeof(msg)/sizeof(msg[0]));
  1708. X}
  1709. X
  1710. X/* callback when the alt/az button changes state.
  1711. X */
  1712. X/* ARGSUSED */
  1713. Xstatic void
  1714. Xsv_aa_cb (w, client, call)
  1715. XWidget w;
  1716. XXtPointer client;
  1717. XXtPointer call;
  1718. X{
  1719. X    double lst;
  1720. X    Now *np;
  1721. X
  1722. X    np = mm_get_now();
  1723. X    now_lst (np, &lst);
  1724. X
  1725. X    if (aa_mode) {
  1726. X        /* change from alt/az to ra/dec mode */
  1727. X        double ha;
  1728. X        unrefract (pressure, temp, sv_altdec, &sv_altdec);
  1729. X        aa_hadec (lat, sv_altdec, sv_azra, &ha, &sv_altdec);
  1730. X        sv_azra = hrrad(lst) - ha;
  1731. X        range (&sv_azra, 2*PI);
  1732. X        if (epoch != EOD)
  1733. X        precess (mjd, epoch, &sv_azra, &sv_altdec);
  1734. X    } else {
  1735. X        /* change from ra/dec to alt/az mode if center is above horizon */
  1736. X        double ha, ra, dec, alt, az;
  1737. X        ra = sv_azra;
  1738. X        dec = sv_altdec;
  1739. X        if (epoch != EOD)
  1740. X        precess (epoch, mjd, &ra, &dec);
  1741. X        ha = hrrad(lst) - ra;
  1742. X        range (&ha, 2*PI);
  1743. X        hadec_aa (lat, ha, dec, &alt, &az);
  1744. X        refract (pressure, temp, alt, &alt);
  1745. X        if (alt < 0.0) {
  1746. X        xe_msg ("Center would be below horizon.", 1);
  1747. X        XmToggleButtonSetState (aa_w, False, False);
  1748. X        XmToggleButtonSetState (rad_w, True, False);
  1749. X        return;
  1750. X        }
  1751. X        sv_altdec = alt;
  1752. X        sv_azra = az;
  1753. X    }
  1754. X
  1755. X    aa_mode ^= 1;
  1756. X    sv_set_scales();
  1757. X    sv_all(np, 1);
  1758. X}
  1759. X
  1760. X/* callback from the filter button.
  1761. X * just toggle the filter dialog.
  1762. X * always restore it to the real state before bringing it up.
  1763. X */
  1764. X/* ARGSUSED */
  1765. Xstatic void
  1766. Xsv_filter_cb (w, client, call)
  1767. XWidget w;
  1768. XXtPointer client;
  1769. XXtPointer call;
  1770. X{
  1771. X    svf_manage_toggle ();
  1772. X}
  1773. X
  1774. X/* callback from the grid button.
  1775. X * if adding the grid just draw it, but if taking it away copy from pixmap.
  1776. X */
  1777. X/* ARGSUSED */
  1778. Xstatic void
  1779. Xsv_grid_cb (w, client, call)
  1780. XWidget w;
  1781. XXtPointer client;
  1782. XXtPointer call;
  1783. X{
  1784. X    want_grid = XmToggleButtonGetState(w);
  1785. X
  1786. X    sv_all(mm_get_now(), 1);
  1787. X
  1788. X    if (!want_grid) {
  1789. X        set_xmstring (vgrid_w, XmNlabelString, null_grid_str);
  1790. X        set_xmstring (hgrid_w, XmNlabelString, null_grid_str);
  1791. X    }
  1792. X}
  1793. X
  1794. X/* set the altdec_w and azra_w scale values, depending on aa_mode and sv_altdec
  1795. X * and sv_azra.
  1796. X */
  1797. Xstatic void
  1798. Xsv_set_scales()
  1799. X{
  1800. X    Arg args[20];
  1801. X    int n;
  1802. X
  1803. X    if (aa_mode) {
  1804. X        int altitude, azimuth;
  1805. X
  1806. X        altitude = raddeg(sv_altdec) + 0.5;
  1807. X        azimuth = raddeg(sv_azra) + 0.5;
  1808. X        if (azimuth >= 360) azimuth -= 360;
  1809. X        if (azimuth < 0) azimuth += 360;
  1810. X
  1811. X        n = 0;
  1812. X        XtSetArg (args[n], XmNprocessingDirection, XmMAX_ON_RIGHT); n++;
  1813. X        XtSetArg (args[n], XmNmaximum, 359); n++;
  1814. X        XtSetArg (args[n], XmNminimum, 0); n++;
  1815. X        XtSetArg (args[n], XmNdecimalPoints, 0); n++;
  1816. X        XtSetArg (args[n], XmNvalue, azimuth); n++;
  1817. X        XtSetValues (azra_w, args, n);
  1818. X
  1819. X        n = 0;
  1820. X        XtSetArg (args[n], XmNmaximum, 90); n++;
  1821. X        XtSetArg (args[n], XmNminimum, 0); n++;
  1822. X        XtSetArg (args[n], XmNvalue, altitude); n++;
  1823. X        XtSetValues (altdec_w, args, n);
  1824. X
  1825. X    } else {
  1826. X        int ra, dec;
  1827. X
  1828. X        ra = radhr(sv_azra)*10.0 + 0.5;
  1829. X        if (ra >= 240) ra -= 240;
  1830. X        dec = raddeg(sv_altdec) + (sv_altdec >= 0 ? 0.5 : -0.5);
  1831. X
  1832. X        n = 0;
  1833. X        XtSetArg (args[n], XmNprocessingDirection, XmMAX_ON_LEFT); n++;
  1834. X        XtSetArg (args[n], XmNmaximum, 239); n++;
  1835. X        XtSetArg (args[n], XmNminimum, 0); n++;
  1836. X        XtSetArg (args[n], XmNdecimalPoints, 1); n++;
  1837. X        XtSetArg (args[n], XmNvalue, ra); n++;
  1838. X        XtSetValues (azra_w, args, n);
  1839. X
  1840. X        n = 0;
  1841. X        XtSetArg (args[n], XmNmaximum, 90); n++;
  1842. X        XtSetArg (args[n], XmNminimum, -90); n++;
  1843. X        XtSetArg (args[n], XmNvalue, dec); n++;
  1844. X        XtSetValues (altdec_w, args, n);
  1845. X    }
  1846. X}
  1847. X
  1848. X/* expose event of sky view drawing area.
  1849. X * if same size just copy from pixmap, else recompute all (it's resized).
  1850. X * N.B. we set bit_gravity to ForgetGravity so we can just use Expose events.
  1851. X * N.B. we turn off backing store since we effectively do it in the pixmap.
  1852. X */
  1853. X/* ARGSUSED */
  1854. Xstatic void
  1855. Xsv_da_exp_cb (w, client, call)
  1856. XWidget w;
  1857. XXtPointer client;
  1858. XXtPointer call;
  1859. X{
  1860. X    static unsigned int wid_last, hei_last;
  1861. X    XmDrawingAreaCallbackStruct *c = (XmDrawingAreaCallbackStruct *)call;
  1862. X    Display *dsp = XtDisplay(w);
  1863. X    Window win = XtWindow(w);
  1864. X    Window root;
  1865. X    int x, y;
  1866. X    unsigned int bw, d;
  1867. X    unsigned wid, hei;
  1868. X
  1869. X
  1870. X    switch (c->reason) {
  1871. X    case XmCR_EXPOSE: {
  1872. X        static before;
  1873. X        XExposeEvent *e = &c->event->xexpose;
  1874. X        if (!before) {
  1875. X        XSetWindowAttributes swa;
  1876. X        unsigned long mask = CWBitGravity | CWBackingStore;
  1877. X        swa.bit_gravity = ForgetGravity;
  1878. X        swa.backing_store = NotUseful;
  1879. X        XChangeWindowAttributes (e->display, e->window, mask, &swa);
  1880. X        before = 1;
  1881. X        }
  1882. X        /* wait for the last in the series */
  1883. X        if (e->count != 0)
  1884. X        return;
  1885. X        break;
  1886. X        }
  1887. X    default:
  1888. X        printf ("Unexpected svda_w event. type=%d\n", c->reason);
  1889. X        exit(1);
  1890. X    }
  1891. X
  1892. X    XGetGeometry (dsp, win, &root, &x, &y, &wid, &hei, &bw, &d);
  1893. X
  1894. X    if (!sv_pm || wid != wid_last || hei != hei_last) {
  1895. X        if (sv_pm)
  1896. X        XFreePixmap (dsp, sv_pm);
  1897. X
  1898. X        if (!sv_gc)
  1899. X        sv_mk_gcs(dsp, win);
  1900. X
  1901. X        sv_pm = XCreatePixmap (dsp, win, wid, hei, d);
  1902. X        wid_last = wid;
  1903. X        hei_last = hei;
  1904. X
  1905. X        sv_all(mm_get_now(), 1);
  1906. X    } else {
  1907. X        /* same size; just copy from the pixmap */
  1908. X        sv_copy_sky();
  1909. X    }
  1910. X}
  1911. X
  1912. X/* copy the pixmap to the drawing area
  1913. X */
  1914. Xstatic void
  1915. Xsv_copy_sky()
  1916. X{
  1917. X    Display *dsp = XtDisplay (svda_w);
  1918. X    Window win = XtWindow (svda_w);
  1919. X    unsigned wid, hei;    /* overall width and height */
  1920. X    unsigned int r;        /* circle radius */
  1921. X    unsigned int xb, yb;    /* x and y border */
  1922. X
  1923. X    sv_getcircle (&wid, &hei, &r, &xb, &yb);
  1924. X
  1925. X    XCopyArea (dsp, sv_pm, win, sv_gc, 0, 0, wid, hei, 0, 0);
  1926. X}
  1927. X
  1928. X/* called on receipt of a MotionNotify or ButtonPress or ButtonRelease event
  1929. X *   while the cursor is wandering over the sky view and button 1 is down.
  1930. X * we report the current location in world coordinates.
  1931. X */
  1932. X/* ARGSUSED */
  1933. Xstatic void
  1934. Xsv_da_motion_cb (w, client, ev, continue_to_dispatch)
  1935. XWidget w;
  1936. XXtPointer client;
  1937. XXEvent *ev;
  1938. XBoolean *continue_to_dispatch;
  1939. X{
  1940. X    Now *np = mm_get_now();
  1941. X    unsigned int wide, h, r, xb, yb;
  1942. X    double altdec, azra;
  1943. X    Window root, child;
  1944. X    int rx, ry, wx, wy;
  1945. X    unsigned mask;
  1946. X    char alt_buf[64], az_buf[64];
  1947. X    char ra_buf[64], dec_buf[64];
  1948. X    int evt = ev->type;
  1949. X    int okmotion, okbutton;
  1950. X    double lst;
  1951. X
  1952. X    /* only interested if motion event or button 1 press/release */
  1953. X    okmotion = evt == MotionNotify && ev->xmotion.state == Button1Mask;
  1954. X    okbutton = (evt == ButtonPress || evt == ButtonRelease)
  1955. X                    && ev->xbutton.button == Button1;
  1956. X    if (!okmotion && !okbutton)
  1957. X        return;
  1958. X
  1959. X    now_lst (np, &lst);
  1960. X
  1961. X    XQueryPointer (XtDisplay(w), XtWindow(w),
  1962. X                &root, &child, &rx, &ry, &wx, &wy, &mask);
  1963. X
  1964. X    sv_getcircle (&wide, &h, &r, &xb, &yb);
  1965. X
  1966. X    if (evt != ButtonRelease && sv_unloc (r, wx-xb, wy-yb, &altdec, &azra)){
  1967. X        double ha, ra, dec, alt, az;
  1968. X
  1969. X        if (aa_mode) {
  1970. X        /* need to make the ra/dec entries */
  1971. X        alt = altdec;
  1972. X        az = azra;
  1973. X        unrefract (pressure, temp, altdec, &altdec);
  1974. X        aa_hadec (lat, altdec, azra, &ha, &dec);
  1975. X        ra = hrrad(lst) - ha;
  1976. X        range (&ra, 2*PI);
  1977. X        if (epoch != EOD)
  1978. X            precess (mjd, epoch, &ra, &dec);
  1979. X        } else {
  1980. X        /* need to make the alt/az entries */
  1981. X        ra = azra;
  1982. X        dec = altdec;
  1983. X        if (epoch != EOD)
  1984. X            precess (epoch, mjd, &azra, &altdec);
  1985. X        ha = hrrad(lst) - azra;
  1986. X        range (&ha, 2*PI);
  1987. X        hadec_aa (lat, ha, altdec, &alt, &az);
  1988. X        refract (pressure, temp, alt, &alt);
  1989. X        }
  1990. X
  1991. X        (void) strcpy (alt_buf, "Alt: ");
  1992. X        fs_angle (alt_buf+5, alt);
  1993. X        (void) strcpy (az_buf, "Az: ");
  1994. X        fs_angle (az_buf+4, az);
  1995. X        (void) strcpy (ra_buf, "RA: ");
  1996. X        fs_ra (ra_buf+4, ra);
  1997. X        (void) strcpy (dec_buf, "Dec: ");
  1998. X        fs_angle (dec_buf+5, dec);
  1999. X    } else {
  2000. X        (void) strcpy (alt_buf, " ");
  2001. X        (void) strcpy (az_buf, " ");
  2002. X        (void) strcpy (ra_buf, " ");
  2003. X        (void) strcpy (dec_buf, " ");
  2004. X    }
  2005. X
  2006. X    f_showit (talt_w, alt_buf);
  2007. X    f_showit (taz_w, az_buf);
  2008. X    f_showit (tra_w, ra_buf);
  2009. X    f_showit (tdec_w, dec_buf);
  2010. X}
  2011. X
  2012. X/* a dot has been picked:
  2013. X * find what it is and report stuff about it in a popup.
  2014. X */
  2015. X/* ARGSUSED */
  2016. Xstatic void
  2017. Xsv_da_input_cb (w, client, call)
  2018. XWidget w;
  2019. XXtPointer client;
  2020. XXtPointer call;
  2021. X{
  2022. X#define    PICKRANGE    100    /* sqr of dist allowed from pointer */
  2023. X    XmDrawingAreaCallbackStruct *c = (XmDrawingAreaCallbackStruct *)call;
  2024. X    XEvent *ev;
  2025. X    TrailObj *top;
  2026. X    unsigned int wide, h, r, xb, yb;
  2027. X    int x, y;
  2028. X    int mind = 1000000;    /* min distance to far */
  2029. X    TSky *mintsp = NULL;    /* set to a TSky if find one close */
  2030. X    Obj *minop = NULL;    /* set to an Obj if find one closer */
  2031. X    Obj *op;
  2032. X    int cx, cy;
  2033. X    int d;
  2034. X    int i;
  2035. X
  2036. X    if (c->reason != XmCR_INPUT)
  2037. X        return;
  2038. X    ev = c->event;
  2039. X    if (ev->xany.type != ButtonPress || ev->xbutton.button != 3)
  2040. X        return;
  2041. X
  2042. X    watch_cursor(1);
  2043. X
  2044. X    sv_getcircle (&wide, &h, &r, &xb, &yb);
  2045. X
  2046. X    /* search everything based on cursor loc within the circle */
  2047. X    cx = ev->xbutton.x - xb;
  2048. X    cy = ev->xbutton.y - yb;
  2049. X
  2050. X    /* search the trailed stuff first because
  2051. X     * the first entry in a trailing list will be both in the db and in
  2052. X     * the trails list -- we want to find the latter when we can.
  2053. X     */
  2054. X    for (top = trailobj; top; top = top->ntop) {
  2055. X        if (!top->on)
  2056. X        continue;
  2057. X        for (i = 0; i < top->nsky; i++) {
  2058. X        if (!sv_trailobjloc (&top->sky[i], r, &x, &y))
  2059. X            continue;
  2060. X        d = (cx - x)*(cx - x) + (cy - y)*(cy - y);
  2061. X        if (d < mind) {
  2062. X            mintsp = &top->sky[i];
  2063. X            mind = d;
  2064. X        }
  2065. X        }
  2066. X    }
  2067. X
  2068. X    /* search the database too -- might be something closer */
  2069. X    for (op = db_next(NULL, OBJS_ALL); op; op = db_next(op, OBJS_ALL)) {
  2070. X        if (!(op->o_flags & OBJF_ONSCREEN))
  2071. X        continue;
  2072. X        if (!sv_dbobjloc (op, r, &x, &y))
  2073. X        continue;    /* not in the circle now */
  2074. X        d = (cx - x)*(cx - x) + (cy - y)*(cy - y);
  2075. X        if (d < mind) {
  2076. X        minop = op;
  2077. X        mind = d;
  2078. X        }
  2079. X    }
  2080. X
  2081. X    if (mind <= PICKRANGE)
  2082. X        sv_popup (ev, minop, minop ? NULL : mintsp);
  2083. X
  2084. X    watch_cursor(0);
  2085. X}
  2086. X
  2087. X/* callback when any of the scales change value.
  2088. X */
  2089. X/* ARGSUSED */
  2090. Xstatic void
  2091. Xsv_changed_cb (w, client, call)
  2092. XWidget w;
  2093. XXtPointer client;
  2094. XXtPointer call;
  2095. X{
  2096. X    sv_set_view();
  2097. X    sv_all(mm_get_now(), 1);
  2098. X}
  2099. X
  2100. X/* callback when the "just dots" toggle button changes state.
  2101. X */
  2102. X/* ARGSUSED */
  2103. Xstatic void
  2104. Xsv_justdots_cb (w, client, call)
  2105. XWidget w;
  2106. XXtPointer client;
  2107. XXtPointer call;
  2108. X{
  2109. X    justdots = XmToggleButtonGetState (w);
  2110. X    sv_all(mm_get_now(), 1);
  2111. X}
  2112. X
  2113. X/* callback when the "ecliptic" toggle button changes state.
  2114. X */
  2115. X/* ARGSUSED */
  2116. Xstatic void
  2117. Xsv_ecliptic_cb (w, client, call)
  2118. XWidget w;
  2119. XXtPointer client;
  2120. XXtPointer call;
  2121. X{
  2122. X    want_ecliptic = XmToggleButtonGetState (w);
  2123. X    sv_all(mm_get_now(), 1);
  2124. X}
  2125. X
  2126. X/* callback when the "all labels" toggle button changes state.
  2127. X */
  2128. X/* ARGSUSED */
  2129. Xstatic void
  2130. Xsv_all_labels_cb (w, client, call)
  2131. XWidget w;
  2132. XXtPointer client;
  2133. XXtPointer call;
  2134. X{
  2135. X    all_labels = XmToggleButtonGetState (w);
  2136. X    sv_all(mm_get_now(), 1);
  2137. X}
  2138. X
  2139. X/* callback when the "Find" cascade button is activated.
  2140. X * check the used defined objects and adjust the cascade buttons accordingly.
  2141. X */
  2142. X/* ARGSUSED */
  2143. Xstatic void
  2144. Xsv_finding_cb (wid, client, call)
  2145. XWidget wid;
  2146. XXtPointer client;
  2147. XXtPointer call;
  2148. X{
  2149. X    int i;
  2150. X
  2151. X    for (i = 0; i < 2; i++) {
  2152. X        Obj *op = db_basic (i == 0 ? OBJX : OBJY);
  2153. X        Widget w = find_w[i];
  2154. X        if (op->type == UNDEFOBJ)
  2155. X        XtUnmanageChild (w);
  2156. X        else {
  2157. X        set_xmstring (w, XmNlabelString, op->o_name);
  2158. X        XtManageChild (w);
  2159. X        }
  2160. X    }
  2161. X}
  2162. X
  2163. X/* callback when one of the "point" cascade buttons changes state.
  2164. X * object index is in client.
  2165. X */
  2166. X/* ARGSUSED */
  2167. Xstatic void
  2168. Xsv_find_cb (w, client, call)
  2169. XWidget w;
  2170. XXtPointer client;
  2171. XXtPointer call;
  2172. X{
  2173. X    Obj *op = db_basic((int)client);
  2174. X
  2175. X    switch (sv_id (op)) {
  2176. X    case 0: 
  2177. X        break;
  2178. X    case -1:
  2179. X        xe_msg ("Object is below the horizon now", 1);
  2180. X        break;
  2181. X    case -2:
  2182. X        sv_point (op);
  2183. X        break;
  2184. X    }
  2185. X}
  2186. X
  2187. X/* callback as either magnitude scale is dragged.
  2188. X * enforce at least a 1 mag window.
  2189. X*/
  2190. X/* ARGSUSED */
  2191. Xstatic void
  2192. Xsv_magdrag_cb (w, client, call)
  2193. XWidget w;
  2194. XXtPointer client;
  2195. XXtPointer call;
  2196. X{
  2197. X    int f, b;
  2198. X
  2199. X    XmScaleGetValue (fmag_w, &f);
  2200. X    XmScaleGetValue (bmag_w, &b);
  2201. X    if (f - b < 1)
  2202. X        XmScaleSetValue (w, w == fmag_w ? b+1 : f-1);
  2203. X}
  2204. X
  2205. X/* read the scales and alt-az widgets into the global variables that
  2206. X * describe our current display conditions.
  2207. X */
  2208. Xstatic void
  2209. Xsv_set_view()
  2210. X{
  2211. X    int i;
  2212. X
  2213. X    XmScaleGetValue (fov_w, &i);
  2214. X    sv_fov = degrad(i);
  2215. X
  2216. X    XmScaleGetValue (bmag_w, &bmag);
  2217. X    XmScaleGetValue (fmag_w, &fmag);
  2218. X
  2219. X    XmScaleGetValue (altdec_w, &i);
  2220. X    sv_altdec = degrad(i);
  2221. X    XmScaleGetValue (azra_w, &i);
  2222. X    sv_azra = aa_mode ? degrad(i) : hrrad((double)i/10.0);
  2223. X}
  2224. X
  2225. X/* return the current circle info about svda_w */
  2226. Xstatic void
  2227. Xsv_getcircle (wp, hp, rp, xbp, ybp)
  2228. Xunsigned int *wp, *hp;        /* overall width and height */
  2229. Xunsigned int *rp;        /* circle radius */
  2230. Xunsigned int *xbp, *ybp;    /* x and y border */
  2231. X{
  2232. X    Display *dsp = XtDisplay(svda_w);
  2233. X    Window win = XtWindow(svda_w);
  2234. X    Window root;
  2235. X    int x, y;
  2236. X    unsigned int w, h;
  2237. X    unsigned int bw, d;
  2238. X
  2239. X    XGetGeometry (dsp, win, &root, &x, &y, wp, hp, &bw, &d);
  2240. X    w = *wp/2;
  2241. X    h = *hp/2;
  2242. X    *rp = w > h ? h : w;    /* radius */
  2243. X    *xbp = w - *rp;        /* x border */
  2244. X    *ybp = h - *rp;        /* y border */
  2245. X
  2246. X}
  2247. X
  2248. X/* fill in the popup with goodies from db object *op or *tsp if it is set:
  2249. X *   if tsp is set use it's Obj -- this is a trailed object.
  2250. X * position the popup as indicated by ev and display it.
  2251. X * it goes down by itself.
  2252. X */
  2253. Xstatic void
  2254. Xsv_popup (ev, op, tsp)
  2255. XXEvent *ev;
  2256. XObj *op;
  2257. XTSky *tsp;
  2258. X{
  2259. X    char buf[32], buf2[64];
  2260. X    int trail;
  2261. X    int label;
  2262. X    double jd;
  2263. X
  2264. X    if (tsp) {
  2265. X        /* we were given a trailed Obj */
  2266. X        TrailObj *top;
  2267. X        op = &tsp->o;
  2268. X        jd = tsp->ts_mjd;
  2269. X        top = tobj_find (op);
  2270. X        trail = top->on;
  2271. X        label = !!(tsp->flags & OBJF_LABEL);
  2272. X    } else {
  2273. X        /* no tsp trail -- just use the db */
  2274. X        Now *np = mm_get_now();
  2275. X        jd = mjd;
  2276. X        trail = 0;
  2277. X        label = !!(op->o_flags & OBJF_LABEL);
  2278. X    }
  2279. X
  2280. X    XmToggleButtonSetState (pu.trail_w, trail, False);
  2281. X    XmToggleButtonSetState (pu.label_w, label, False);
  2282. X
  2283. X    pu.op = op;
  2284. X    pu.tsp = tsp;
  2285. X
  2286. X    (void) sprintf (buf2, "   Name: %.20s", op->o_name);
  2287. X    set_xmstring (pu.name_w, XmNlabelString, buf2);
  2288. X
  2289. X    (void) sprintf (buf2, "   Type: %.20s", obj_description(op));
  2290. X    set_xmstring (pu.desc_w, XmNlabelString, buf2);
  2291. X
  2292. X    if (op->type == FIXED && op->f_spect[0]) {
  2293. X        (void) sprintf (buf2, "  Spect: %.*s", sizeof(op->f_spect),
  2294. X                                op->f_spect);
  2295. X        set_xmstring (pu.spect_w, XmNlabelString, buf2);
  2296. X        XtManageChild (pu.spect_w);
  2297. X    } else
  2298. X        XtUnmanageChild (pu.spect_w);
  2299. X
  2300. X    fs_date (buf, jd);
  2301. X    (void) sprintf (buf2, "UT Date: %s", buf);
  2302. X    set_xmstring (pu.ud_w, XmNlabelString, buf2);
  2303. X
  2304. X    fs_time (buf, mjd_hr(jd));
  2305. X    (void) sprintf (buf2, "UT Time: %s", buf);
  2306. X    set_xmstring (pu.ut_w, XmNlabelString, buf2);
  2307. X
  2308. X    fs_ra (buf, op->s_ra);
  2309. X    (void) sprintf (buf2, "     RA: %s", buf);
  2310. X    set_xmstring (pu.ra_w, XmNlabelString, buf2);
  2311. X
  2312. X    fs_angle (buf, op->s_dec);
  2313. X    (void) sprintf (buf2, "    Dec: %s", buf);
  2314. X    set_xmstring (pu.dec_w, XmNlabelString, buf2);
  2315. X
  2316. X    fs_angle (buf, op->s_alt);
  2317. X    (void) sprintf (buf2, "    Alt: %s", buf);
  2318. X    set_xmstring (pu.alt_w, XmNlabelString, buf2);
  2319. X
  2320. X    fs_angle (buf, op->s_az);
  2321. X    (void) sprintf (buf2, "     Az: %s", buf);
  2322. X    set_xmstring (pu.az_w, XmNlabelString, buf2);
  2323. X
  2324. X    (void) sprintf (buf2, "    Mag: %.3g", op->s_mag/MAGSCALE);
  2325. X    set_xmstring (pu.mag_w, XmNlabelString, buf2);
  2326. X
  2327. X    XmMenuPosition (pu.pu_w, (XButtonPressedEvent *)ev);
  2328. X    XtManageChild (pu.pu_w);
  2329. X}
  2330. X
  2331. X/* create the id popup */
  2332. Xstatic void
  2333. Xsv_create_popup()
  2334. X{
  2335. X    static Widget *puw[] = {
  2336. X        &pu.name_w,
  2337. X        &pu.desc_w,
  2338. X        &pu.spect_w,
  2339. X        &pu.ud_w,
  2340. X        &pu.ut_w,
  2341. X        &pu.ra_w,
  2342. X        &pu.dec_w,
  2343. X        &pu.alt_w,
  2344. X        &pu.az_w,
  2345. X        &pu.mag_w,
  2346. X    };
  2347. X    Arg args[20];
  2348. X    XmString str;
  2349. X    Widget w;
  2350. X    int i, n;
  2351. X
  2352. X    /* create the outer form */
  2353. X    n = 0;
  2354. X    XtSetArg (args[n], XmNisAligned, True); n++;
  2355. X    XtSetArg (args[n], XmNentryAlignment, XmALIGNMENT_CENTER); n++;
  2356. X    pu.pu_w = XmCreatePopupMenu (toplevel_w, "SVPopup", args, n);
  2357. X
  2358. X    /* create the label widgets */
  2359. X
  2360. X    for (i = 0; i < XtNumber(puw); i++) {
  2361. X        n = 0;
  2362. X        *puw[i] = XmCreateLabel (pu.pu_w, "SVPopValueL", args, n);
  2363. X        XtManageChild (*puw[i]);
  2364. X    }
  2365. X
  2366. X    /* add a nice separator */
  2367. X    n = 0;
  2368. X    w = XmCreateSeparator (pu.pu_w, "SVSep", args, n);
  2369. X    XtManageChild(w);
  2370. X
  2371. X    /* make the "aim", "ObjX" and "trail" command buttons */
  2372. X
  2373. X    str = XmStringCreateLtoR ("Point", XmSTRING_DEFAULT_CHARSET);
  2374. X    n = 0;
  2375. X    XtSetArg (args[n], XmNlabelString, str); n++;
  2376. X    w = XmCreatePushButton (pu.pu_w, "SVPopPoint", args, n);
  2377. X    XtAddCallback (w, XmNactivateCallback, sv_pu_activate_cb,
  2378. X                                (XtPointer)AIM);
  2379. X    XtManageChild (w);
  2380. X    XmStringFree (str);
  2381. X
  2382. X    str = XmStringCreateLtoR ("Make ObjX/Y", XmSTRING_DEFAULT_CHARSET);
  2383. X    n = 0;
  2384. X    XtSetArg (args[n], XmNlabelString, str); n++;
  2385. X    w = XmCreatePushButton (pu.pu_w, "SVPopMakeObj", args, n);
  2386. X    XtAddCallback (w, XmNactivateCallback, sv_pu_activate_cb,
  2387. X                            (XtPointer)MK_OBJX);
  2388. X    XtManageChild (w);
  2389. X    XmStringFree(str);
  2390. X
  2391. X    str = XmStringCreateLtoR ("Leave Trail", XmSTRING_DEFAULT_CHARSET);
  2392. X    n = 0;
  2393. X    XtSetArg (args[n], XmNlabelString, str); n++;
  2394. X    XtSetArg (args[n], XmNvisibleWhenOff, True); n++;
  2395. X    pu.trail_w = XmCreateToggleButton (pu.pu_w, "SVPopTrail", args, n);
  2396. X    XtAddCallback(pu.trail_w, XmNvalueChangedCallback, sv_pu_trail_cb,NULL);
  2397. X    XtManageChild (pu.trail_w);
  2398. X    XmStringFree(str);
  2399. X
  2400. X    str = XmStringCreateLtoR ("Persistent Label", XmSTRING_DEFAULT_CHARSET);
  2401. X    n = 0;
  2402. X    XtSetArg (args[n], XmNlabelString, str); n++;
  2403. X    XtSetArg (args[n], XmNvisibleWhenOff, True); n++;
  2404. X    pu.label_w = XmCreateToggleButton (pu.pu_w, "SVPopLabel", args, n);
  2405. X    XtAddCallback(pu.label_w, XmNvalueChangedCallback, sv_pu_label_cb,NULL);
  2406. X    XtManageChild (pu.label_w);
  2407. X    XmStringFree(str);
  2408. X}
  2409. X
  2410. X/* called when any of the popup's pushbuttons are activated.
  2411. X * client is a code to indicate which.
  2412. X */
  2413. X/* ARGSUSED */
  2414. Xstatic void
  2415. Xsv_pu_activate_cb (w, client, call)
  2416. XWidget w;
  2417. XXtPointer client;
  2418. XXtPointer call;
  2419. X{
  2420. X    switch ((int)client) {
  2421. X    case AIM:
  2422. X        sv_point (pu.tsp ? &pu.tsp->o : pu.op);
  2423. X        break;
  2424. X    case MK_OBJX: {
  2425. X        switch (pu.op->type) {
  2426. X        case HYPERBOLIC: case PARABOLIC: case ELLIPTICAL: case FIXED:
  2427. X        sv_ournewobj = 1;
  2428. X        obj_set (pu.op);
  2429. X        sv_ournewobj = 0;
  2430. X        break;
  2431. X        default:
  2432. X        xe_msg ("User objects can not be of that type.", 0);
  2433. X        break;
  2434. X        }
  2435. X        }
  2436. X        break;
  2437. X    }
  2438. X}
  2439. X
  2440. X/* called when the Trail popup toggle button changes.
  2441. X * clean up the trailobj stuff.
  2442. X */
  2443. X/* ARGSUSED */
  2444. Xstatic void
  2445. Xsv_pu_trail_cb (wid, client, call)
  2446. XWidget wid;
  2447. XXtPointer client;
  2448. XXtPointer call;
  2449. X{
  2450. X    if (XmToggleButtonGetState(wid)) {
  2451. X        /* trail is being turned on.
  2452. X         * if it already has a trail just turn it back on and draw it, else
  2453. X         *   add a new db obj to trailobj list.
  2454. X         */
  2455. X        TrailObj *top = tobj_find (pu.op);
  2456. X        if (top) {
  2457. X        unsigned int w, h, r, xb, yb;
  2458. X        sv_getcircle (&w, &h, &r, &xb, &yb);
  2459. X        top->on = 1;
  2460. X        tobj_display_all(r, xb, yb);
  2461. X        sv_copy_sky();
  2462. X        } else {
  2463. X        Now *np = mm_get_now();
  2464. X        top = tobj_addobj (pu.op);
  2465. X        (void) tobj_addsky (top, mjd, pu.op);
  2466. X        /* no need to redraw since a trail of lenth 1 won't *look*
  2467. X         * any different.
  2468. X         */
  2469. X        }
  2470. X    } else {
  2471. X        /* trailing is being turned off. mark it as being off.
  2472. X         * it will get removed at the next update if it's still off.
  2473. X         * redraw sky so it disappears.
  2474. X         */
  2475. X        TrailObj *top = tobj_find (pu.op);
  2476. X        top->on = 0;
  2477. X        sv_all (mm_get_now(), 1);
  2478. X    }
  2479. X}
  2480. X
  2481. X/* called when the Label popup toggle button changes.
  2482. X * we get all context from the pu structure.
  2483. X */
  2484. X/* ARGSUSED */
  2485. Xstatic void
  2486. Xsv_pu_label_cb (wid, client, call)
  2487. XWidget wid;
  2488. XXtPointer client;
  2489. XXtPointer call;
  2490. X{
  2491. X    unsigned int w, h, r, xb, yb;
  2492. X    int x, y;
  2493. X    int label;
  2494. X    char *name;
  2495. X
  2496. X    /* if this is a trailed item then its TSky will be in pu.tsp
  2497. X     * otherwise it is a plain db object.
  2498. X     * either way, toggle the corresponding OBJF_LABEL bit too.
  2499. X     */
  2500. X    if (pu.tsp) {
  2501. X        label = (pu.tsp->flags ^= OBJF_LABEL) & OBJF_LABEL;
  2502. X        if (label) {
  2503. X        sv_getcircle (&w, &h, &r, &xb, &yb);
  2504. X        (void) sv_trailobjloc (pu.tsp, r, &x, &y);
  2505. X        name = pu.tsp->o.o_name;
  2506. X        }
  2507. END_OF_FILE
  2508.   if test 26155 -ne `wc -c <'skyviewmenu.c.2'`; then
  2509.     echo shar: \"'skyviewmenu.c.2'\" unpacked with wrong size!
  2510.   fi
  2511.   # end of 'skyviewmenu.c.2'
  2512. fi
  2513. echo shar: End of archive 17 \(of 21\).
  2514. cp /dev/null ark17isdone
  2515. MISSING=""
  2516. 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
  2517.     if test ! -f ark${I}isdone ; then
  2518.     MISSING="${MISSING} ${I}"
  2519.     fi
  2520. done
  2521. if test "${MISSING}" = "" ; then
  2522.     echo You have unpacked all 21 archives.
  2523.     rm -f ark[1-9]isdone ark[1-9][0-9]isdone
  2524.     echo Building ephem.db
  2525.     cat > ephem.db.Z.uu ephem.db.Z.uu.?
  2526.     uudecode ephem.db.Z.uu
  2527.     rm ephem.db.Z.uu ephem.db.Z.uu.?
  2528.     uncompress ephem.db.Z
  2529.     echo Building skyviewmenu.c
  2530.     cat > skyviewmenu.c skyviewmenu.c.?
  2531.     rm skyviewmenu.c.?
  2532.     echo Building smallfm.xbm
  2533.     cat > smallfm.xbm smallfm.xbm.?
  2534.     rm smallfm.xbm.?
  2535. else
  2536.     echo You still must unpack the following archives:
  2537.     echo "        " ${MISSING}
  2538. fi
  2539. exit 0
  2540. exit 0 # Just in case...
  2541. -- 
  2542.   // chris@IMD.Sterling.COM            | Send comp.sources.x submissions to:
  2543. \X/  Amiga - The only way to fly!      |
  2544.  "It's intuitively obvious to the most |    sources-x@imd.sterling.com
  2545.   casual observer..."                  |
  2546.