home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1994 March / Source_Code_CD-ROM_Walnut_Creek_March_1994.iso / compsrcs / x / volume16 / xephem / part11 < prev    next >
Encoding:
Text File  |  1992-03-05  |  50.3 KB  |  1,749 lines

  1. Newsgroups: comp.sources.x
  2. Path: uunet!think.com!mips!msi!dcmartin
  3. From: e_downey@hwking.cca.cr.rockwell.com (Elwood Downey)
  4. Subject: v16i122: xephem - astronomical ephemeris program., Part11/24
  5. Message-ID: <1992Mar6.135441.2468@msi.com>
  6. Originator: dcmartin@fascet
  7. Sender: dcmartin@msi.com (David C. Martin - Moderator)
  8. Organization: Molecular Simulations, Inc.
  9. References: <csx-16i112-xephem@uunet.UU.NET>
  10. Date: Fri, 6 Mar 1992 13:54:41 GMT
  11. Approved: dcmartin@msi.com
  12.  
  13. Submitted-by: e_downey@hwking.cca.cr.rockwell.com (Elwood Downey)
  14. Posting-number: Volume 16, Issue 122
  15. Archive-name: xephem/part11
  16.  
  17. # this is part.11 (part 11 of a multipart archive)
  18. # do not concatenate these parts, unpack them in order with /bin/sh
  19. # file sun.c continued
  20. #
  21. if test ! -r _shar_seq_.tmp; then
  22.     echo 'Please unpack part 1 first!'
  23.     exit 1
  24. fi
  25. (read Scheck
  26.  if test "$Scheck" != 11; then
  27.     echo Please unpack part "$Scheck" next!
  28.     exit 1
  29.  else
  30.     exit 0
  31.  fi
  32. ) < _shar_seq_.tmp || exit 1
  33. if test ! -f _shar_wnt_.tmp; then
  34.     echo 'x - still skipping sun.c'
  35. else
  36. echo 'x - continuing file sun.c'
  37. sed 's/^X//' << 'SHAR_EOF' >> 'sun.c' &&
  38. X    b = 360*(a-(long)a);
  39. X    c1 = degrad(312.69+b);
  40. X    a = 1236.853095*t;
  41. X    b = 360*(a-(long)a);
  42. X    d1 = degrad(350.74-.00144*t2+b);
  43. X    e1 = degrad(231.19+20.2*t);
  44. X    a = 183.1353208*t;
  45. X    b = 360*(a-(long)a);
  46. X    h1 = degrad(353.4+b);
  47. X    dl = .00134*cos(a1)+.00154*cos(b1)+.002*cos(c1)+.00179*sin(d1)+
  48. X                                .00178*sin(e1);
  49. X    dr = 5.43e-06*sin(a1)+1.575e-05*sin(b1)+1.627e-05*sin(c1)+
  50. X                        3.076e-05*cos(d1)+9.27e-06*sin(h1);
  51. X    *lsn = nu+degrad(ls-ms+dl);
  52. X    *rsn = 1.0000002*(1-s*cos(ea))+dr;
  53. X    range (lsn, 2*PI);
  54. }
  55. SHAR_EOF
  56. echo 'File sun.c is complete' &&
  57. chmod 0644 sun.c ||
  58. echo 'restore of sun.c failed'
  59. Wc_c="`wc -c < 'sun.c'`"
  60. test 1760 -eq "$Wc_c" ||
  61.     echo 'sun.c: original size 1760, current size' "$Wc_c"
  62. rm -f _shar_wnt_.tmp
  63. fi
  64. # ============= time.c ==============
  65. if test -f 'time.c' -a X"$1" != X"-c"; then
  66.     echo 'x - skipping time.c (File already exists)'
  67.     rm -f _shar_wnt_.tmp
  68. else
  69. > _shar_wnt_.tmp
  70. echo 'x - extracting time.c (Text)'
  71. sed 's/^X//' << 'SHAR_EOF' > 'time.c' &&
  72. /* get the time from the os.
  73. X *
  74. X * here are two methods I was able to verify; pick one for your system and
  75. X *   define exactly one of TZA or TZB:
  76. X * TZA works on our ibm-pc/turbo-c and at&t systems,
  77. X * TZB works on our 4.2 BSD vax.
  78. X *
  79. X * I'm told that on Sun OS 4.0.3 (BSD 4.3?) and Apollo SR 10.1 TZB works if
  80. X *   you use <sys/time.h> in place of <time.h>.
  81. X * 
  82. X * On VMS, you DON'T want to define EITHER TZA nor TZB since it can't handle
  83. X *   time zones, period. time_fromsys() will detect that fact based on gmtime()
  84. X *   returning 0.
  85. X */
  86. X
  87. /* try to infer a setting for TZ?
  88. X */
  89. #ifdef SYSV
  90. #define    TZA
  91. #endif
  92. #ifdef BSD
  93. #define    TZB
  94. #endif
  95. #ifdef BSD43
  96. #define    TZB
  97. #endif
  98. #ifdef ultrix
  99. #define    TZB
  100. #endif
  101. X
  102. /* default to TZA */
  103. #ifndef TZA
  104. #ifndef TZB
  105. #define    TZA
  106. #endif
  107. #endif
  108. X
  109. #ifdef VMS
  110. #undef TZA
  111. #undef TZB
  112. #endif
  113. X
  114. #ifdef VAXC
  115. #undef TZA
  116. #undef TZB
  117. #include <time.h>
  118. #endif
  119. X
  120. #include <stdio.h>
  121. #ifdef TZA
  122. #include <time.h>
  123. #endif
  124. #ifdef TZB
  125. #include <sys/time.h>
  126. #endif
  127. X
  128. #include "astro.h"
  129. #include "circum.h"
  130. X
  131. extern char *strncpy();
  132. #ifndef VMS
  133. extern long time();
  134. #endif
  135. X
  136. static long c0;
  137. static double mjd0;
  138. X
  139. /* save current mjd and corresponding system clock for use by inc_mjd().
  140. X * this establishes the base correspondence between the mjd and system clock.
  141. X */
  142. set_t0 (np)
  143. Now *np;
  144. {
  145. X    mjd0 = mjd;
  146. X    (void) time (&c0);
  147. }
  148. X
  149. /* fill in n_mjd/tz/tznm from system clock.
  150. X */
  151. time_fromsys (np)
  152. Now *np;
  153. {
  154. X    extern struct tm *gmtime(), *localtime();
  155. X    struct tm *tp;
  156. X    long c;
  157. X    double day, hr;
  158. X
  159. X    (void) time (&c);
  160. X
  161. X    tp = gmtime (&c);
  162. X    if (tp) {
  163. X        cal_mjd (tp->tm_mon+1, (double)tp->tm_mday, tp->tm_year+1900, &day);
  164. X        sex_dec (tp->tm_hour, tp->tm_min, tp->tm_sec, &hr);
  165. X        mjd = day + hr/24.0;
  166. X        tp = localtime (&c);
  167. X        settzstuff (tp->tm_isdst ? 1 : 0, np);
  168. X    } else {
  169. X        /* if gmtime() doesn't work, we assume the timezone stuff won't
  170. X         * either, so we just use what it is and leave it alone. Some
  171. X         * systems (like VMS) do not know about time zones, so this is the
  172. X         * best guess in that case.
  173. X         */
  174. X        tp = localtime (&c);
  175. X        cal_mjd (tp->tm_mon+1, (double)tp->tm_mday, tp->tm_year+1900, &day);
  176. X        sex_dec (tp->tm_hour, tp->tm_min, tp->tm_sec, &hr);
  177. X        mjd = day + hr/24.0 + tz/24.0;
  178. X    }
  179. }
  180. X
  181. /* given whether dst is now in effect (must be strictly 0 or 1), fill in
  182. X * tzname and tz within np.
  183. X */
  184. static
  185. settzstuff (dst, np)
  186. int dst;
  187. Now *np;
  188. {
  189. #ifdef TZA
  190. X    extern long timezone;
  191. X    extern char *tzname[2];
  192. X
  193. X    tzset();
  194. X    tz = timezone/3600;
  195. X    if (dst)
  196. X        tz -= 1.0;
  197. X    (void) strncpy (tznm, tzname[dst], sizeof(tznm)-1);
  198. #endif
  199. #ifdef TZB
  200. X    extern char *timezone();
  201. X    struct timeval timev;
  202. X    struct timezone timez;
  203. X
  204. X    gettimeofday (&timev, &timez);
  205. X    tz = timez.tz_minuteswest/60;
  206. X    if (dst)
  207. X        tz -= 1.0;
  208. X    (void) strncpy (tznm, timezone(timez.tz_minuteswest, dst),
  209. X                                sizeof(tznm)-1);
  210. #endif
  211. X    tznm[sizeof(tznm)-1] = '\0';    /* insure string is terminated */
  212. }
  213. X
  214. inc_mjd (np, inc)
  215. Now *np;
  216. double inc;
  217. {
  218. X    if (inc == RTC) {
  219. X        long c;
  220. X        (void) time (&c);
  221. X        mjd = mjd0 + (c - c0)/SPD;
  222. X    } else
  223. X        mjd += inc/24.0;
  224. X
  225. X    /* round to nearest whole second.
  226. X     * without this, you can get fractional days so close to .5 but
  227. X     * not quite there that mjd_hr() can return 24.0
  228. X     */
  229. X    rnd_second (&mjd);
  230. }
  231. SHAR_EOF
  232. chmod 0644 time.c ||
  233. echo 'restore of time.c failed'
  234. Wc_c="`wc -c < 'time.c'`"
  235. test 3230 -eq "$Wc_c" ||
  236.     echo 'time.c: original size 3230, current size' "$Wc_c"
  237. rm -f _shar_wnt_.tmp
  238. fi
  239. # ============= utc_gst.c ==============
  240. if test -f 'utc_gst.c' -a X"$1" != X"-c"; then
  241.     echo 'x - skipping utc_gst.c (File already exists)'
  242.     rm -f _shar_wnt_.tmp
  243. else
  244. > _shar_wnt_.tmp
  245. echo 'x - extracting utc_gst.c (Text)'
  246. sed 's/^X//' << 'SHAR_EOF' > 'utc_gst.c' &&
  247. #include "astro.h"
  248. X
  249. /* given a modified julian date, mjd, and a universally coordinated time, utc,
  250. X * return greenwich mean siderial time, *gst.
  251. X */
  252. utc_gst (mjd, utc, gst)
  253. double mjd;
  254. double utc;
  255. double *gst;
  256. {
  257. X    double tnaught();
  258. X    static double lastmjd = -10000;
  259. X    static double t0;
  260. X
  261. X    if (mjd != lastmjd) {
  262. X        t0 = tnaught (mjd);
  263. X        lastmjd = mjd;
  264. X    }
  265. X    *gst = (1.0/SIDRATE)*utc + t0;
  266. X    range (gst, 24.0);
  267. }
  268. X
  269. /* given a modified julian date, mjd, and a greenwich mean siderial time, gst,
  270. X * return universally coordinated time, *utc.
  271. X */
  272. gst_utc (mjd, gst, utc)
  273. double mjd;
  274. double gst;
  275. double *utc;
  276. {
  277. X    double tnaught();
  278. X    static double lastmjd = -10000;
  279. X    static double t0;
  280. X
  281. X    if (mjd != lastmjd) {
  282. X        t0 = tnaught (mjd);
  283. X        range (&t0, 24.0);
  284. X        lastmjd = mjd;
  285. X    }
  286. X    *utc = gst - t0;
  287. X    range (utc, 24.0);
  288. X    *utc *= SIDRATE;
  289. }
  290. X
  291. static double
  292. tnaught (mjd)
  293. double mjd;    /* julian days since 1900 jan 0.5 */
  294. {
  295. X    double dmjd;
  296. X    int m, y;
  297. X    double d;
  298. X    double t, t0;
  299. X
  300. X    mjd_cal (mjd, &m, &d, &y);
  301. X    cal_mjd (1, 0., y, &dmjd);
  302. X    t = dmjd/36525;
  303. X    t0 = 6.57098e-2 * (mjd - dmjd) - 
  304. X         (24 - (6.6460656 + (5.1262e-2 + (t * 2.581e-5))*t) -
  305. X           (2400 * (t - (((double)y - 1900)/100))));
  306. X    return (t0);
  307. }
  308. SHAR_EOF
  309. chmod 0644 utc_gst.c ||
  310. echo 'restore of utc_gst.c failed'
  311. Wc_c="`wc -c < 'utc_gst.c'`"
  312. test 1189 -eq "$Wc_c" ||
  313.     echo 'utc_gst.c: original size 1189, current size' "$Wc_c"
  314. rm -f _shar_wnt_.tmp
  315. fi
  316. # ============= version.c ==============
  317. if test -f 'version.c' -a X"$1" != X"-c"; then
  318.     echo 'x - skipping version.c (File already exists)'
  319.     rm -f _shar_wnt_.tmp
  320. else
  321. > _shar_wnt_.tmp
  322. echo 'x - extracting version.c (Text)'
  323. sed 's/^X//' << 'SHAR_EOF' > 'version.c' &&
  324. /* code to manage the stuff on the version display.
  325. X * first thing is our modification history, then code to put up the dialog.
  326. X */
  327. X
  328. /* increment version and date and add a note after each change.
  329. X * increment PATCHLEVEL, in patchlevel.h, after each patch is distributed.
  330. X */
  331. static char vmsg[] = "Version 1.0 February 24, 1992";
  332. X
  333. /*
  334. X * 1.0 2/24/92    baseline release to comp.sources.x.
  335. X * .19 1/17    invert icon pixmap.
  336. X *        change default font to "fixed".
  337. X *     1/24    fix {} bugs around case XmCR_RESIZE events.
  338. X *     1/27    change to XX_all() to XX_update() in sol/altaz/sky view exposes.
  339. X *     1/29    date/sep/riset: toggle object state, don't force all on or off.
  340. X *     2/3    add toggle buttons to altaz/sky/solsys views as well.
  341. X *     2/7    call XmProcessTraversal() >>twice<< to set PromptDialog focus.
  342. X *     2/10    clean up widget names.
  343. X *     2/11    better plot file error messages.
  344. X *     2/13    add patchlevel.h.
  345. X *     2/19    many small changes, as per beta test feedback...
  346. X *     2/20    fix version background color.
  347. X *        add bigdots toggle to jupmenu and fix expose bug.
  348. X *     2/21    add resources XEphem.plotColor[0-9] to set plot colors.
  349. X *     2/24    allow trailing s on step size to indicate sidereal days.
  350. X * .18 1/14    always show ddd:mm in sep menu.
  351. X *     1/16    move moonmenu loc to fallbacks.
  352. X * .17 1/3/92    rework menu schemes a bit to better handle different font sizes.
  353. X * .16 11/27    switch to using XtAppContext with timer.
  354. X *        add error checking in get_xmstring().
  355. X *        add "if (!w)" to all the *_ison() functions.
  356. X *     12/16    obj.c: switch to XmListDeleteAllItems - Motif 1.1!!
  357. X *        add check for m_ison() in main's ANYTHING_ISON macro.
  358. X *     12/23    set resizePolicy to RESIZE_NONE in skydome.c and moonmenu.c
  359. X * .15 9/18    work up a nicer version menu.
  360. X *     9/19    rearrange obj menu and fix trailing \n List bug.
  361. X * .14 8/28    add help file facility.
  362. X *     9/4    add some optional earthshine to bitmapped moon scene.
  363. X *     9/5    f_sscansex: allow for decimal seconds.
  364. X *     9/9    allow user to toggle between moon views, and tweak them a bit.
  365. X * .13 8/14    add Moon to View menu.
  366. X *     8/21    obj.c: nxt_db(): add isdigit() to allow numeric entries.
  367. X *     8/22    add "big dots" options to views.
  368. X *             allow building up trails even while views are unmanaged.
  369. X * .12 8/6    fixed nesting of selection buttons.
  370. X *     8/7    add "All on/off" pushbuttons.
  371. X *        teach f_string() not to set string if it didn't change.
  372. X *        circum.c: about_now(): turn off change storage - not good enuf.
  373. X *     8/8    obj.c: obj_crack_dbline(): loop from 2 .. sizeof(ids)+2
  374. X *        add more built-in functions to the compiler.
  375. X * .11 7/31    first do-nothing search menu.
  376. X *     8/2    completed search menu but don't like compiler messages much.
  377. X * .10        skip so nobody rounds 0.10 to 0.1 somewhere sometime.
  378. X * 0.9 6/12    add test for !lstform in lst_selection()
  379. X *        get di by get_something(w,XmNuserData,&di) in plt_da_unmap_cb()
  380. X *        use l-3, not l-2, in XDrawString call in plot_cartesian()
  381. X *        add test for (propts&(1<<points[i].p)) in {aa,sd,ss}_identify()
  382. X *     7/9    remove internet address from version notice.
  383. X *     7/12    print cal after loop stops: mm_calendar(): add f_ison() check
  384. X *     7/17    mainmenu.c: mm_activate_cb(): only select of how & PLT
  385. X * 0.8 1/17    refinements to graphical displays. change Update/Stop button.
  386. X *     1/18    swap order of mm_readcfg() and mm_crackargs()
  387. X *     1/21    PROPTS sets initial objects on for all menus.
  388. X *     1/22    remove the Help button from obj's prompts.
  389. X *     1/23    just Stop stops looping.
  390. X *     3/18    update times when stop an automatic looping run.
  391. X * 0.7 1/11    added alt/az display.
  392. X * 0.6 1/10    added sky dome display
  393. X * 0.5 1/8    eliminate .uil file (about 10% smaller program now)
  394. X * 0.4 1/7/91    par with ephem now except for alt/az & dome skies and searching.
  395. X * 0.1 12/13/90 first viable beginnings. main three menus working ok.
  396. X */
  397. X
  398. #include <stdio.h>
  399. #include <ctype.h>
  400. #include <math.h>
  401. #ifdef VMS
  402. #include <stdlib.h>
  403. #endif
  404. #include <X11/Xlib.h>
  405. #include <Xm/Xm.h>
  406. #include <Xm/Form.h>
  407. #include <Xm/Frame.h>
  408. #include <Xm/DrawingA.h>
  409. #include <Xm/LabelG.h>
  410. #include <Xm/PushBG.h>
  411. #include <Xm/ToggleBG.h>
  412. #include <Xm/Text.h>
  413. #include <Xm/Scale.h>
  414. #include "astro.h"
  415. #include "circum.h"
  416. #include "moreobjs.h"
  417. #include "patchlevel.h"
  418. X
  419. extern Widget toplevel_w;
  420. extern XtAppContext xe_app;
  421. X
  422. static char *msg[] = {
  423. "xephem - An Interactive Astronomical Ephemeris Program for X",
  424. vmsg,
  425. 0, /* placeholder for PATCHLEVEL message */
  426. "",
  427. "Copyright (c) 1990,1991,1992 by Elwood Charles Downey",
  428. "",
  429. "Permission is granted to make and distribute copies of this program free of",
  430. "charge, provided the copyright notices and this permission notice are",
  431. "preserved on all copies.  All other rights reserved.  No representation is",
  432. "made about the suitability of this software for any purpose.  It is provided",
  433. "\"as is\" without express or implied warranty, to the extent permitted by",
  434. "applicable law.",
  435. };
  436. X
  437. #define    NMSGR    (sizeof(msg)/sizeof(msg[0]))
  438. X
  439. static Widget v_w;
  440. static Widget vda_w;
  441. static XtIntervalId v_timer_id;
  442. static GC v_fgc;
  443. static double rotrate;    /* rotation rate constant - filled on first manage */
  444. X
  445. /* table of circular orbit radii to portray and the last screen coords.
  446. X * the real solar system has planet radii from .3 to 30, but the 100:1 ratio is
  447. X * so large we don't try and include everything.
  448. X */
  449. typedef struct {
  450. X    double r;        /* radius, AU */
  451. X    double theta;    /* angle */
  452. X    int x, y;        /* last X x,y coord drawn */
  453. } Orbit;
  454. X
  455. #define    UNDEFX    (-1)        /* value of x when never drawn yet */
  456. static Orbit orbit[] = {
  457. X    /*
  458. X    {1.0, 0.0, UNDEFX, 0},
  459. X    */
  460. X    {1.6, 0.0, UNDEFX, 0},
  461. X    {5.4, 0.0, UNDEFX, 0},
  462. X    {10., 0.0, UNDEFX, 0},
  463. X    {19., 0.0, UNDEFX, 0},
  464. X    {30., 0.0, UNDEFX, 0}
  465. };
  466. #define NORBIT    (sizeof(orbit)/sizeof(orbit[0]))
  467. #define    MAXRAD    (orbit[NORBIT-1].r)    /* N.B.use orbit[] with largest radius*/
  468. #define    MINRAD    (orbit[0].r)    /* N.B. use orbit[] with smallest radius */
  469. #define PR     4        /* radius of planet, in pixels */
  470. #define    DT    100        /* ms pause between screen updates */
  471. #define    NSTARS    100        /* number of background stars to sprinkle in */
  472. #define    DPI    30        /* degrees of inner orbit motion per iteration*/
  473. X
  474. /* called when mainmenu "on Version" help is selected.
  475. X */
  476. version()
  477. {
  478. X    /* make the version form if this is our first time.
  479. X     * also take this opportunity to do things once to init the
  480. X     * planet locations and set the rotation rate.
  481. X     */
  482. X    if (!v_w) {
  483. X        int i;
  484. X        v_makew();
  485. X        for (i = 0; i < NORBIT; i++)
  486. X        orbit[i].theta = ((rand()>>2) & 0xfff) * 2*PI / 0xfff;
  487. X        rotrate = degrad(DPI)/pow(MINRAD/MAXRAD, -3./2.);
  488. X    }
  489. X        
  490. X    /* toggle whether up now.
  491. X     * autoUnmanage can bring back down too.
  492. X     */
  493. X    if (XtIsManaged(v_w))
  494. X        XtUnmanageChild (v_w);
  495. X    else
  496. X        XtManageChild (v_w);
  497. }
  498. X
  499. /* make the v_w widget.
  500. X */
  501. static
  502. v_makew()
  503. {
  504. X    void v_unmap_cb();
  505. X    void v_da_exp_cb();
  506. X    Widget w;
  507. X    Widget ok_w;
  508. X    Widget frame_w;
  509. X    Widget text_w;
  510. X    XmString str;
  511. X    Arg args[20];
  512. X    int x, y;
  513. X    int n;
  514. X
  515. X    /* get location of our main app menu and place nearby */
  516. X    n = 0;
  517. X    XtSetArg (args[n], XmNx, &x); n++;
  518. X    XtSetArg (args[n], XmNy, &y); n++;
  519. X    XtGetValues (toplevel_w, args, n);
  520. X
  521. X    /* create form */
  522. X    n = 0;
  523. X    XtSetArg (args[n], XmNunitType, Xm100TH_FONT_UNITS); n++;
  524. X    XtSetArg (args[n], XmNheight, (2*NMSGR+1)*250); n++;
  525. X    XtSetArg (args[n], XmNwidth, 84*100); n++;
  526. X    XtSetArg (args[n], XmNresizePolicy, XmRESIZE_ANY); n++;
  527. X    XtSetArg (args[n], XmNautoUnmanage, True); n++;
  528. X    XtSetArg (args[n], XmNhorizontalSpacing, 100); n++;
  529. X    XtSetArg (args[n], XmNverticalSpacing, 75); n++;
  530. X    XtSetArg (args[n], XmNx, 10*x+200); n++;
  531. X    XtSetArg (args[n], XmNy, 10*y+200); n++;
  532. X    v_w = XmCreateFormDialog (toplevel_w, "Version", args, n);
  533. X    XtAddCallback (v_w, XmNunmapCallback, v_unmap_cb, 0);
  534. X
  535. X    /* set some stuff in the parent DialogShell.
  536. X     * setting XmNdialogTitle in the Form didn't work..
  537. X     */
  538. X    n = 0;
  539. X    XtSetArg (args[n], XmNtitle, "xephem Version"); n++;
  540. X    XtSetValues (XtParent(v_w), args, n);
  541. X
  542. X    /* make text widget for the version info */
  543. X
  544. X    XtSetArg (args[n], XmNtopAttachment, XmATTACH_FORM); n++;
  545. X    XtSetArg (args[n], XmNbottomAttachment, XmATTACH_POSITION); n++;
  546. X    XtSetArg (args[n], XmNbottomPosition, 50); n++;
  547. X    XtSetArg (args[n], XmNleftAttachment, XmATTACH_FORM); n++;
  548. X    XtSetArg (args[n], XmNrightAttachment, XmATTACH_FORM); n++;
  549. X    XtSetArg (args[n], XmNeditMode, XmMULTI_LINE_EDIT); n++;
  550. X    XtSetArg (args[n], XmNeditable, False); n++;
  551. X    text_w = XmCreateScrolledText (v_w, "VText", args, n);
  552. X    fill_msg (text_w);
  553. X    XtManageChild (text_w);
  554. X
  555. X    /* make the "Ok" push button */
  556. X
  557. X    str = XmStringCreate("Ok", XmSTRING_DEFAULT_CHARSET);
  558. X    n = 0;
  559. X    XtSetArg (args[n], XmNbottomAttachment, XmATTACH_FORM); n++;
  560. X    XtSetArg (args[n], XmNleftAttachment, XmATTACH_FORM); n++;
  561. X    XtSetArg (args[n], XmNshowAsDefault, True); n++;
  562. X    XtSetArg (args[n], XmNlabelString, str); n++;
  563. X    ok_w = XmCreatePushButtonGadget (v_w, "VOk", args, n);
  564. X    XtManageChild (ok_w);
  565. X    XmStringFree (str);
  566. X    set_something (v_w, XmNdefaultButton, ok_w);
  567. X
  568. X    /* make a frame for the drawing area */
  569. X
  570. X    n = 0;
  571. X    XtSetArg (args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
  572. X    XtSetArg (args[n], XmNtopWidget, XtParent(text_w)); n++;
  573. X    XtSetArg (args[n], XmNbottomAttachment, XmATTACH_WIDGET); n++;
  574. X    XtSetArg (args[n], XmNbottomWidget, ok_w); n++;
  575. X    XtSetArg (args[n], XmNleftAttachment, XmATTACH_POSITION); n++;
  576. X    XtSetArg (args[n], XmNleftPosition, 20); n++;
  577. X    XtSetArg (args[n], XmNrightAttachment, XmATTACH_POSITION); n++;
  578. X    XtSetArg (args[n], XmNrightPosition, 80); n++;
  579. X    XtSetArg (args[n], XmNshadowType, XmSHADOW_ETCHED_OUT); n++;
  580. X    frame_w = XmCreateFrame (v_w, "VFrame", args, n);
  581. X    XtManageChild (frame_w);
  582. X
  583. X    /* make a drawing area for drawing the solar system */
  584. X
  585. X    n = 0;
  586. X    vda_w = XmCreateDrawingArea (frame_w, "VMap", args, n);
  587. X    XtAddCallback (vda_w, XmNexposeCallback, v_da_exp_cb, 0);
  588. X    XtAddCallback (vda_w, XmNresizeCallback, v_da_exp_cb, 0);
  589. X    XtManageChild (vda_w);
  590. }
  591. X
  592. static
  593. fill_msg (w)
  594. Widget w;
  595. {
  596. X    char m[100*NMSGR], *mp = m;
  597. X    char patchmsg[100];
  598. X    int i;
  599. X
  600. X    sprintf (patchmsg, "Patch level %d", PATCHLEVEL);
  601. X    msg[2] = patchmsg;    /* "2" must match placeholder location! */
  602. X
  603. X    /* Generate message to display as one string */
  604. X    for (i = 0; i < NMSGR; i++) {
  605. X        (void) sprintf (mp, "%*s%s\n", (78 - strlen(msg[i]))/2, "", msg[i]);
  606. X        mp += strlen(mp);
  607. X    }
  608. X
  609. X    /* remove final \n to avoid extra blank line at end */
  610. X    *--mp = '\0';
  611. X
  612. X    XmTextSetString (w, m);
  613. }
  614. X
  615. /* version dialog is going away.
  616. X * stop the rotation timer.
  617. X */
  618. static void
  619. v_unmap_cb (w, client, call)
  620. Widget w;
  621. caddr_t client;
  622. caddr_t call;
  623. {
  624. X    if (v_timer_id) {
  625. X        XtRemoveTimeOut (v_timer_id);
  626. X        v_timer_id = 0;
  627. X    }
  628. }
  629. X
  630. /* expose version drawing area.
  631. X * redraw the scene to the (new?) size.
  632. X */
  633. static void
  634. v_da_exp_cb (w, client, call)
  635. Widget w;
  636. caddr_t client;
  637. caddr_t call;
  638. {
  639. X    XmDrawingAreaCallbackStruct *c = (XmDrawingAreaCallbackStruct *)call;
  640. X
  641. X    switch (c->reason) {
  642. X    case XmCR_RESIZE:
  643. X        /* seems we can get one resize before the first expose.
  644. X         * hence, we don't have a good window to use yet. just let it
  645. X         * go; we'll get the expose soon.
  646. X         */
  647. X        if (!XtWindow(w))
  648. X        return;
  649. X        break;
  650. X    case XmCR_EXPOSE: {
  651. X        XExposeEvent *e = &c->event->xexpose;
  652. X        /* wait for the last in the series */
  653. X        if (e->count != 0)
  654. X        return;
  655. X        break;
  656. X        }
  657. X    default:
  658. X        printf ("Unexpected v_w event. type=%d\n", c->reason);
  659. X        return;
  660. X    }
  661. X
  662. X    v_draw();
  663. }
  664. X
  665. static
  666. v_draw()
  667. {
  668. X    Display *dsp = XtDisplay(vda_w);
  669. X    Window win = XtWindow(vda_w);
  670. X    unsigned int w, h;
  671. X    Window root;
  672. X    int x, y;
  673. X    unsigned int bw, d;
  674. X    int i;
  675. X
  676. X    if (!v_fgc)
  677. X        v_define_fgc();
  678. X
  679. X    XGetGeometry(dsp, win, &root, &x, &y, &w, &h, &bw, &d);
  680. X    XClearWindow (dsp, win);
  681. X
  682. X    /* draw the orbit ellipsii and forget last drawn locs */
  683. X    for (i = 0; i < NORBIT; i++) {
  684. X        int lx, ty;    /* left and top x */
  685. X        int nx, ny; /* width and height */
  686. X        lx = w/2 - orbit[i].r/MAXRAD*w/2 + 0.5;
  687. X        nx = orbit[i].r/MAXRAD*w + 0.5;
  688. X        ty = h/2 - orbit[i].r/MAXRAD*h/2 + 0.5;
  689. X        ny = orbit[i].r/MAXRAD*h + 0.5;
  690. X        XDrawArc (dsp, win, v_fgc, lx, ty, nx-1, ny-1, 0, 360*64);
  691. X        orbit[i].x = UNDEFX;
  692. X    }
  693. X
  694. X    /* draw sun at the center */
  695. X    drawPlanet (dsp, win, v_fgc, w/2-PR, h/2-PR, 2*PR-1, 2*PR-1);
  696. X
  697. X    /* draw some background stars */
  698. X    for (i = 0; i < NSTARS; i++) {
  699. X        int sx, sy;
  700. X        sx = ((rand()>>2) & 0xfff) * (w-1) / 0xfff;
  701. X        sy = ((rand()>>2) & 0xfff) * (h-1) / 0xfff;
  702. X        XDrawPoint (dsp, win, v_fgc, sx, sy);
  703. X    }
  704. X
  705. X    if (!v_timer_id)
  706. X        v_timer_cb (0, 0);
  707. X
  708. }
  709. X
  710. /* called whenever the timer goes off.
  711. X * we advance all the planets, draw any that have moved at least a few
  712. X * pixels, and restart a timer.
  713. X */
  714. static
  715. v_timer_cb (client, id)
  716. caddr_t client;
  717. XXtIntervalId *id;
  718. {
  719. X    Display *dsp = XtDisplay(vda_w);
  720. X    Window win = XtWindow(vda_w);
  721. X    unsigned int w, h;
  722. X    Window root;
  723. X    int x, y;
  724. X    unsigned int bw, d;
  725. X    int i;
  726. X
  727. X    XGetGeometry(dsp, win, &root, &x, &y, &w, &h, &bw, &d);
  728. X
  729. X    for (i = 0; i < NORBIT; i++) {
  730. X        int px, py;    /* planets new center position */
  731. X        double f = orbit[i].r/MAXRAD;    /* fraction of largest radius */
  732. X        orbit[i].theta += rotrate*pow(f, -3./2.);
  733. X        px = w/2 + cos(orbit[i].theta)*w*f/2 + 0.5;
  734. X        py = h/2 - sin(orbit[i].theta)*h*f/2 + 0.5;
  735. X        if (px != orbit[i].x || py != orbit[i].y) {
  736. X        /* erase then redraw at new pos, using the XOR GC */
  737. X        if (orbit[i].x != UNDEFX)
  738. X            drawPlanet (dsp, win, v_fgc,
  739. X                orbit[i].x-PR, orbit[i].y-PR, 2*PR-1, 2*PR-1);
  740. X        drawPlanet (dsp, win, v_fgc, px-PR, py-PR, 2*PR-1, 2*PR-1);
  741. X        orbit[i].x = px;
  742. X        orbit[i].y = py;
  743. X        }
  744. X    }
  745. X
  746. X    v_timer_id = XtAppAddTimeOut (xe_app, DT, v_timer_cb, 0);
  747. }
  748. X
  749. /* draw the planet.
  750. X * would use XFillArc but it is VERY SLOW on the IBM 6091 X terminal.
  751. X */
  752. static
  753. drawPlanet (dsp, win, gc, sx, sy, w, h)
  754. Display *dsp;
  755. Window win;
  756. GC gc;
  757. int sx, sy, w, h;
  758. {
  759. X    int y;
  760. X
  761. X    XFillArc (dsp, win, gc, sx, sy, w, h, 0, 360*64);
  762. X    /*
  763. X    for (y = sy; y <= sy+h; y++) 
  764. X        XDrawLine (dsp, win, gc, sx, y, sx+w, y);
  765. X    */
  766. }
  767. X
  768. static
  769. v_define_fgc()
  770. {
  771. X    Display *dsp = XtDisplay(vda_w);
  772. X    Window win = XtWindow(vda_w);
  773. X    XGCValues gcv;
  774. X    unsigned int gcm;
  775. X    Pixel fg, bg;
  776. X
  777. X    gcm = GCForeground | GCFunction;
  778. X    get_something (vda_w, XmNforeground, (char *)&fg);
  779. X    get_something (vda_w, XmNbackground, (char *)&bg);
  780. X    gcv.foreground = fg ^ bg;
  781. X    gcv.function = GXxor;
  782. X    v_fgc = XCreateGC (dsp, win, gcm, &gcv);
  783. }
  784. SHAR_EOF
  785. chmod 0644 version.c ||
  786. echo 'restore of version.c failed'
  787. Wc_c="`wc -c < 'version.c'`"
  788. test 14200 -eq "$Wc_c" ||
  789.     echo 'version.c: original size 14200, current size' "$Wc_c"
  790. rm -f _shar_wnt_.tmp
  791. fi
  792. # ============= xephem.c ==============
  793. if test -f 'xephem.c' -a X"$1" != X"-c"; then
  794.     echo 'x - skipping xephem.c (File already exists)'
  795.     rm -f _shar_wnt_.tmp
  796. else
  797. > _shar_wnt_.tmp
  798. echo 'x - extracting xephem.c (Text)'
  799. sed 's/^X//' << 'SHAR_EOF' > 'xephem.c' &&
  800. /* main() for xephem.
  801. X */
  802. X
  803. #include <stdio.h>
  804. X
  805. #include <X11/Xlib.h>
  806. #include <Xm/Xm.h>
  807. #include <X11/Shell.h>
  808. #include <Xm/PushB.h>
  809. #include <Xm/CascadeB.h>
  810. #include <Xm/Form.h>
  811. #include <Xm/Separator.h>
  812. #include <Xm/MainW.h>
  813. #include <Xm/RowColumn.h>
  814. X
  815. /* client arg to m_activate_cb().
  816. X */
  817. #define    QUIT        0
  818. #define    DATA        1
  819. #define    RISET        2
  820. #define    SEP        3
  821. #define    JUPMOON        4
  822. #define    ALTAZ        5
  823. #define    DOME        6
  824. #define    SOLARSYS    7
  825. #define    PLOT        8
  826. #define    LIST        9
  827. #define    SEARCH        10
  828. #define    OBJXY        11
  829. #define    VERSION        12
  830. #define    MOON        13
  831. #define    REFERENCES    14
  832. #define    INTRO        15
  833. #define    CONFIGFILE    16
  834. #define    DATETIME    17
  835. #define    OPERATION    18
  836. #define    NOTES        19
  837. X
  838. Widget toplevel_w;
  839. XXtAppContext xe_app;
  840. X
  841. #define xephem_width 50
  842. #define xephem_height 50
  843. static char xephem_bits[] = {
  844. X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  845. X   0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  846. X   0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00,
  847. X   0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00,
  848. X   0x00, 0x00, 0xf8, 0xff, 0xff, 0x7f, 0x00, 0x00, 0xc0, 0x07, 0x00, 0x00,
  849. X   0xa0, 0x0f, 0x00, 0x3c, 0x00, 0x00, 0x00, 0x10, 0xf0, 0x00, 0x02, 0x00,
  850. X   0x00, 0x00, 0x0c, 0x00, 0x01, 0x01, 0x00, 0x00, 0x08, 0x0c, 0x00, 0x02,
  851. X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  852. X   0x00, 0x00, 0x00, 0x00, 0xfc, 0xff, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x03,
  853. X   0x00, 0x0f, 0x00, 0x00, 0x00, 0x3c, 0x00, 0x00, 0xf0, 0x0c, 0x00, 0x00,
  854. X   0x03, 0x00, 0x00, 0x00, 0x1f, 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x1e,
  855. X   0x00, 0x30, 0x00, 0xf8, 0x7f, 0x00, 0x3c, 0x00, 0x08, 0xb0, 0x07, 0x80,
  856. X   0x07, 0x40, 0x00, 0x04, 0x78, 0x00, 0x00, 0x18, 0x80, 0x00, 0x04, 0x78,
  857. X   0x00, 0x00, 0x20, 0x80, 0x00, 0x02, 0x30, 0x00, 0x02, 0x20, 0x00, 0x01,
  858. X   0x02, 0x08, 0x80, 0x0f, 0x40, 0x00, 0x01, 0x82, 0x08, 0x00, 0x07, 0x40,
  859. X   0x00, 0x01, 0x02, 0x08, 0x80, 0x0f, 0x40, 0x00, 0x01, 0x02, 0x10, 0x00,
  860. X   0x02, 0x20, 0x04, 0x01, 0x04, 0x10, 0x00, 0x00, 0x20, 0x80, 0x00, 0x04,
  861. X   0x60, 0x00, 0x00, 0x18, 0x80, 0x00, 0x08, 0x80, 0x07, 0x80, 0x07, 0x40,
  862. X   0x00, 0x30, 0x00, 0xf8, 0x7f, 0x00, 0x30, 0x00, 0xc0, 0x00, 0x00, 0x00,
  863. X   0x00, 0x0c, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x3c,
  864. X   0x00, 0x00, 0xf0, 0x00, 0x00, 0x00, 0xc0, 0x03, 0x00, 0x0f, 0x00, 0x00,
  865. X   0x00, 0x00, 0xfc, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  866. X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00,
  867. X   0x00, 0x00, 0x00, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x3c,
  868. X   0x00, 0x00, 0x00, 0x60, 0xf0, 0x00, 0xc0, 0x07, 0x00, 0x00, 0xf0, 0x0f,
  869. X   0x00, 0x00, 0xf8, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  870. X   0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  871. X   0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x20, 0x00,
  872. X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  873. X   0x00, 0x00};
  874. X
  875. String fallbacks[] = {
  876. X    "XEphem*traversalOn:           false",
  877. X
  878. X    "XEphem*highlightOnEnter:    false",
  879. X    "XEphem*highlightThickness:    0",
  880. X
  881. X    "XEphem*XmText*traversalOn:       true",
  882. X    "XEphem*XmText*highlightOnEnter:    false",
  883. X    "XEphem*XmText*highlightThickness:    0",
  884. X
  885. X    "XEphem*Data.x: 100",
  886. X    "XEphem*Data.y: 200",
  887. X    "XEphem*Riset.x: 150",
  888. X    "XEphem*Riset.y: 250",
  889. X    "XEphem*Separation.x: 200",
  890. X    "XEphem*Separation.y: 300",
  891. X    "XEphem*Jupiter.x: 100",
  892. X    "XEphem*Jupiter.y: 200",
  893. X    "XEphem*SkyDome.x: 150",
  894. X    "XEphem*SkyDome.y: 250",
  895. X    "XEphem*AltAz.x: 200",
  896. X    "XEphem*AltAz.y: 300",
  897. X    "XEphem*SolarSystem.x: 250",
  898. X    "XEphem*SolarSystem.y: 350",
  899. X    "XEphem*Plot.x: 100",
  900. X    "XEphem*Plot.y: 200",
  901. X    "XEphem*List.x: 150",
  902. X    "XEphem*List.y: 250",
  903. X    "XEphem*Srch.x: 200",
  904. X    "XEphem*Srch.y: 300",
  905. X    "XEphem*MoonForm.x: 200",
  906. X    "XEphem*MoonForm.y: 200",
  907. X
  908. X    "XEphem*foreground: #fce089",
  909. X    "XEphem*background: #7c8498",
  910. X
  911. X    "XEphem*fontList: fixed",
  912. X
  913. X    "XEphem*JupMap*background: black",
  914. X    "XEphem*JupMap*foreground: white",
  915. X    "XEphem*AltAzMap*background: black",
  916. X    "XEphem*AltAzMap*foreground: white",
  917. X    "XEphem*SolarMap*background: black",
  918. X    "XEphem*SolarMap*foreground: white",
  919. X    "XEphem*SkyDomeMap*background: black",
  920. X    "XEphem*SkyDomeMap*foreground: white",
  921. X    "XEphem*PlotDA*foreground: white",
  922. X    "XEphem*PlotDA*background: black",
  923. X    "XEphem.plotColor0: red",
  924. X    "XEphem.plotColor1: green",
  925. X    "XEphem.plotColor2: blue",
  926. X    "XEphem.plotColor3: orange",
  927. X    "XEphem.plotColor4: magenta",
  928. X    "XEphem.plotColor5: cyan",
  929. X    "XEphem.plotColor6: black",
  930. X    "XEphem.plotColor7: wheat",
  931. X    "XEphem.plotColor8: gray",
  932. X    "XEphem.plotColor9: pink",
  933. X    "XEphem*MoonDA*foreground: white",
  934. X    "XEphem*MoonDA*background: black",
  935. X    "XEphem*VMap*foreground: white",
  936. X    "XEphem*VMap*background: black",
  937. X    NULL
  938. };
  939. X
  940. main(argc, argv)
  941. unsigned int argc;
  942. char *argv[];
  943. {
  944. X    Widget make_main_window();
  945. X    Widget main_window_w;
  946. X
  947. X    /* init the X Toolkit. We get back a top level shell widget.
  948. X     * XtInit mungs argc and the argv array to take out what it recognizes.
  949. X     */
  950. X    toplevel_w = XtVaAppInitialize (&xe_app, "XEphem", NULL, 0,
  951. X                        &argc, argv, fallbacks, NULL);
  952. X
  953. X    /* make the main menu bar and form (other stuff is in mainmenu.c) */
  954. X    main_window_w = make_main_window (argc, argv);
  955. X
  956. X    /* Manage and realize the main window.
  957. X     * The interface comes up on the display now.
  958. X     */
  959. X    XtManageChild(main_window_w);
  960. X    XtRealizeWidget(toplevel_w);
  961. X
  962. X    /* connect up the icon pixmap */
  963. X    setup_window_properties (toplevel_w);
  964. X
  965. X    /* Sit around forever waiting to process X-events.  We never leave
  966. X     * XtMainLoop. only way out is to call exit. From here on, we only
  967. X     * execute our callback routines.
  968. X     */
  969. X    XtAppMainLoop(xe_app);
  970. }
  971. X
  972. /* put together the menu bar, the main form, and fill in the form with the
  973. X * initial xephem buttons.
  974. X */
  975. static Widget
  976. make_main_window (ac, av)
  977. unsigned int ac;
  978. char *av[];
  979. {
  980. X
  981. X    void m_activate_cb();
  982. X    Widget main_window;
  983. X    Widget menu_bar;
  984. X    Widget menu_pane;
  985. X    Widget button;
  986. X    Widget cascade;
  987. X    Widget w;
  988. X    XmString str;
  989. X    Arg args[20];
  990. X    int n;
  991. X
  992. X    /*    Create MainWindow.  */
  993. X    n = 0;
  994. X    main_window = XmCreateMainWindow (toplevel_w, "xephem_main", args, n);
  995. X    XtManageChild (main_window);
  996. X
  997. X    /*    Create MenuBar in MainWindow.  */
  998. X    n = 0;
  999. X    menu_bar = XmCreateMenuBar (main_window, "menu_bar", args, n); 
  1000. X    XtManageChild (menu_bar);
  1001. X
  1002. X    /*    Create "File" PulldownMenu.  */
  1003. X    n = 0;
  1004. X    menu_pane = XmCreatePulldownMenu (menu_bar, "file_pane", args, n);
  1005. X
  1006. X    n = 0;
  1007. X    XtSetArg (args[n], XmNaccelerator, "Ctrl<Key>d:"); n++;
  1008. X    str = XmStringCreate ("Ctrl/d", XmSTRING_DEFAULT_CHARSET);
  1009. X    XtSetArg (args[n], XmNacceleratorText, str); n++;
  1010. X    XtSetArg (args[n], XmNmnemonic, 'Q'); n++;
  1011. X    button = XmCreatePushButton (menu_pane, "Quit", args, n);
  1012. X    XtManageChild (button);
  1013. X    XtAddCallback (button, XmNactivateCallback, m_activate_cb, QUIT);
  1014. X    XmStringFree (str);
  1015. X
  1016. X    n = 0;
  1017. X    XtSetArg (args[n], XmNsubMenuId, menu_pane);  n++;
  1018. X    XtSetArg (args[n], XmNmnemonic, 'F'); n++;
  1019. X    cascade = XmCreateCascadeButton (menu_bar, "File", args, n);
  1020. X    XtManageChild (cascade);
  1021. X    
  1022. X    /*    Create "View" PulldownMenu.  */
  1023. X    n = 0;
  1024. X    menu_pane = XmCreatePulldownMenu (menu_bar, "view_pane", args, n);
  1025. X    
  1026. X    n = 0;
  1027. X    str = XmStringCreate ("General Data", XmSTRING_DEFAULT_CHARSET);
  1028. X    XtSetArg (args[n], XmNlabelString, str); n++;
  1029. X    XtSetArg (args[n], XmNmnemonic, 'G'); n++;
  1030. X    button = XmCreatePushButton (menu_pane, "GenData", args, n);
  1031. X    XtManageChild (button);
  1032. X    XtAddCallback (button, XmNactivateCallback, m_activate_cb, DATA);
  1033. X    XmStringFree(str);
  1034. X    
  1035. X    n = 0;
  1036. X    str = XmStringCreate ("Rise/Set", XmSTRING_DEFAULT_CHARSET);
  1037. X    XtSetArg (args[n], XmNlabelString, str); n++;
  1038. X    XtSetArg (args[n], XmNmnemonic, 'R'); n++;
  1039. X    button = XmCreatePushButton (menu_pane, "RiSet", args, n);
  1040. X    XtManageChild (button);
  1041. X    XtAddCallback (button, XmNactivateCallback, m_activate_cb, RISET);
  1042. X    XmStringFree(str);
  1043. X    
  1044. X    n = 0;
  1045. X    XtSetArg (args[n], XmNmnemonic, 'S'); n++;
  1046. X    button = XmCreatePushButton (menu_pane, "Separations", args, n);
  1047. X    XtManageChild (button);
  1048. X    XtAddCallback (button, XmNactivateCallback, m_activate_cb, SEP);
  1049. X    
  1050. X    n = 0;
  1051. X    w = XmCreateSeparator (menu_pane, "ViewSep1", args, n);
  1052. X    XtManageChild (w);
  1053. X    
  1054. X    n = 0;
  1055. X    XtSetArg (args[n], XmNmnemonic, 'J'); n++;
  1056. X    button = XmCreatePushButton (menu_pane, "Jupiter", args, n);
  1057. X    XtManageChild (button);
  1058. X    XtAddCallback (button, XmNactivateCallback, m_activate_cb, JUPMOON);
  1059. X    
  1060. X    n = 0;
  1061. X    XtSetArg (args[n], XmNmnemonic, 'M'); n++;
  1062. X    button = XmCreatePushButton (menu_pane, "Moon", args, n);
  1063. X    XtManageChild (button);
  1064. X    XtAddCallback (button, XmNactivateCallback, m_activate_cb, MOON);
  1065. X    
  1066. X    n = 0;
  1067. X    w = XmCreateSeparator (menu_pane, "ViewSep2", args, n);
  1068. X    XtManageChild (w);
  1069. X    
  1070. X    n = 0;
  1071. X    str = XmStringCreate ("Sky dome", XmSTRING_DEFAULT_CHARSET);
  1072. X    XtSetArg (args[n], XmNlabelString, str); n++;
  1073. X    XtSetArg (args[n], XmNmnemonic, 'd'); n++;
  1074. X    button = XmCreatePushButton (menu_pane, "SkyDome", args, n);
  1075. X    XtManageChild (button);
  1076. X    XtAddCallback (button, XmNactivateCallback, m_activate_cb, DOME);
  1077. X    XmStringFree(str);
  1078. X    
  1079. X    n = 0;
  1080. X    str = XmStringCreate ("Alt/Az sky", XmSTRING_DEFAULT_CHARSET);
  1081. X    XtSetArg (args[n], XmNlabelString, str); n++;
  1082. X    XtSetArg (args[n], XmNmnemonic, 'A'); n++;
  1083. X    button = XmCreatePushButton (menu_pane, "AltAz", args, n);
  1084. X    XtManageChild (button);
  1085. X    XtAddCallback (button, XmNactivateCallback, m_activate_cb, ALTAZ);
  1086. X    XmStringFree(str);
  1087. X    
  1088. X    n = 0;
  1089. X    str = XmStringCreate ("Solar system", XmSTRING_DEFAULT_CHARSET);
  1090. X    XtSetArg (args[n], XmNlabelString, str); n++;
  1091. X    XtSetArg (args[n], XmNmnemonic, 'o'); n++;
  1092. X    button = XmCreatePushButton (menu_pane, "SolSys", args, n);
  1093. X    XtManageChild (button);
  1094. X    XtAddCallback (button, XmNactivateCallback, m_activate_cb, SOLARSYS);
  1095. X    XmStringFree(str);
  1096. X    
  1097. X    n = 0;
  1098. X    XtSetArg (args[n], XmNsubMenuId, menu_pane);  n++;
  1099. X    XtSetArg (args[n], XmNmnemonic, 'V'); n++;
  1100. X    cascade = XmCreateCascadeButton (menu_bar, "View", args, n);
  1101. X    XtManageChild (cascade);
  1102. X    
  1103. X    /*    Create "Control" PulldownMenu.  */
  1104. X    n = 0;
  1105. X    menu_pane = XmCreatePulldownMenu (menu_bar, "control_pane", args, n);
  1106. X    
  1107. X    n = 0;
  1108. X    XtSetArg (args[n], XmNmnemonic, 'P'); n++;
  1109. X    button = XmCreatePushButton (menu_pane, "Plot", args, n);
  1110. X    XtManageChild (button);
  1111. X    XtAddCallback (button, XmNactivateCallback, m_activate_cb, PLOT);
  1112. X    
  1113. X    n = 0;
  1114. X    XtSetArg (args[n], XmNmnemonic, 'L'); n++;
  1115. X    button = XmCreatePushButton (menu_pane, "Listing", args, n);
  1116. X    XtManageChild (button);
  1117. X    XtAddCallback (button, XmNactivateCallback, m_activate_cb, LIST);
  1118. X    
  1119. X    n = 0;
  1120. X    XtSetArg (args[n], XmNmnemonic, 'S'); n++;
  1121. X    button = XmCreatePushButton (menu_pane, "Search", args, n);
  1122. X    XtManageChild (button);
  1123. X    XtAddCallback (button, XmNactivateCallback, m_activate_cb, SEARCH);
  1124. X    
  1125. X    n = 0;
  1126. X    XtSetArg (args[n], XmNsubMenuId, menu_pane);  n++;
  1127. X    XtSetArg (args[n], XmNmnemonic, 'C'); n++;
  1128. X    cascade = XmCreateCascadeButton (menu_bar, "Control", args, n);
  1129. X    XtManageChild (cascade);
  1130. X    
  1131. X    /*    Create "ObjX/Y" Cascade Button.  */
  1132. X    n = 0;
  1133. X    XtSetArg (args[n], XmNmnemonic, 'O'); n++;
  1134. X    cascade = XmCreateCascadeButton (menu_bar, "ObjX/Y", args, n);
  1135. X    XtManageChild (cascade);
  1136. X    XtAddCallback (cascade, XmNactivateCallback, m_activate_cb, OBJXY);
  1137. X    
  1138. X    
  1139. X    /*    Create "Help" button.
  1140. X    */
  1141. X    n = 0;
  1142. X    menu_pane = XmCreatePulldownMenu (menu_bar, "help_pane", args, n);
  1143. X    
  1144. X    n = 0;
  1145. X    str = XmStringCreate ("on Version", XmSTRING_DEFAULT_CHARSET);
  1146. X    XtSetArg (args[n], XmNlabelString, str); n++;
  1147. X    XtSetArg (args[n], XmNmnemonic, 'V'); n++;
  1148. X    button = XmCreatePushButton (menu_pane, "onVersion", args, n);
  1149. X    XtManageChild (button);
  1150. X    XtAddCallback (button, XmNactivateCallback, m_activate_cb, VERSION);
  1151. X    XmStringFree(str);
  1152. X
  1153. X    n = 0;
  1154. X    str = XmStringCreate ("on References", XmSTRING_DEFAULT_CHARSET);
  1155. X    XtSetArg (args[n], XmNlabelString, str); n++;
  1156. X    XtSetArg (args[n], XmNmnemonic, 'R'); n++;
  1157. X    button = XmCreatePushButton (menu_pane, "onReferences", args, n);
  1158. X    XtManageChild (button);
  1159. X    XtAddCallback (button, XmNactivateCallback, m_activate_cb, REFERENCES);
  1160. X    XmStringFree(str);
  1161. X
  1162. X    n = 0;
  1163. X    XtSetArg (args[n], XmNmnemonic, 'I'); n++;
  1164. X    button = XmCreatePushButton (menu_pane, "Introduction", args, n);
  1165. X    XtManageChild (button);
  1166. X    XtAddCallback (button, XmNactivateCallback, m_activate_cb, INTRO);
  1167. X
  1168. X    n = 0;
  1169. X    str = XmStringCreate ("on Initialization", XmSTRING_DEFAULT_CHARSET);
  1170. X    XtSetArg (args[n], XmNlabelString, str); n++;
  1171. X    XtSetArg (args[n], XmNmnemonic, 'z'); n++;
  1172. X    button = XmCreatePushButton (menu_pane, "onInitialization", args, n);
  1173. X    XtManageChild (button);
  1174. X    XtAddCallback (button, XmNactivateCallback, m_activate_cb, CONFIGFILE);
  1175. X    XmStringFree(str);
  1176. X
  1177. X    n = 0;
  1178. X    str = XmStringCreate ("on Operation", XmSTRING_DEFAULT_CHARSET);
  1179. X    XtSetArg (args[n], XmNlabelString, str); n++;
  1180. X    XtSetArg (args[n], XmNmnemonic, 'O'); n++;
  1181. X    button = XmCreatePushButton (menu_pane, "onOperation", args, n);
  1182. X    XtManageChild (button);
  1183. X    XtAddCallback (button, XmNactivateCallback, m_activate_cb, OPERATION);
  1184. X    XmStringFree(str);
  1185. X
  1186. X    n = 0;
  1187. X    str = XmStringCreate ("on Date and time formats",
  1188. X                            XmSTRING_DEFAULT_CHARSET);
  1189. X    XtSetArg (args[n], XmNlabelString, str); n++;
  1190. X    XtSetArg (args[n], XmNmnemonic, 'D'); n++;
  1191. X    button = XmCreatePushButton (menu_pane, "onDate", args, n);
  1192. X    XtManageChild (button);
  1193. X    XtAddCallback (button, XmNactivateCallback, m_activate_cb, DATETIME);
  1194. X    XmStringFree(str);
  1195. X
  1196. X    n = 0;
  1197. X    XtSetArg (args[n], XmNmnemonic, 'N'); n++;
  1198. X    button = XmCreatePushButton (menu_pane, "Notes", args, n);
  1199. X    XtManageChild (button);
  1200. X    XtAddCallback (button, XmNactivateCallback, m_activate_cb, NOTES);
  1201. X
  1202. X    n = 0;
  1203. X    XtSetArg (args[n], XmNsubMenuId, menu_pane);  n++;
  1204. X    XtSetArg (args[n], XmNmnemonic, 'H'); n++;
  1205. X    cascade = XmCreateCascadeButton (menu_bar, "Help", args, n);
  1206. X    XtManageChild (cascade);
  1207. X
  1208. X    n = 0;
  1209. X    XtSetArg (args[n], XmNmenuHelpWidget, cascade);  n++;
  1210. X    XtSetValues (menu_bar, args, n);
  1211. X
  1212. X    /* create and manage the main form */
  1213. X    mm_manage(main_window, ac, av);
  1214. X
  1215. X    return (main_window);
  1216. }
  1217. X
  1218. static
  1219. setup_window_properties (w)
  1220. Widget w;
  1221. {
  1222. X    Pixmap icon_pm;
  1223. X    XSizeHints xsh;
  1224. X    Display *dsp = XtDisplay(w);
  1225. X    Window win = XtWindow (w);
  1226. X
  1227. X    icon_pm = XCreateBitmapFromData (dsp, win, xephem_bits, xephem_width,
  1228. X                                xephem_height);
  1229. X    /* can set window size hints here if we like */
  1230. X    xsh.flags = 0;
  1231. X
  1232. X    XSetStandardProperties (dsp, win, "xephem", "xephem", icon_pm,
  1233. X        (char **)0, 0, &xsh);
  1234. }
  1235. X
  1236. /* handy way to set one resource for a widget.
  1237. X * shouldn't use this if you have several things to set for the same widget.
  1238. X */
  1239. set_something (w, resource, value)
  1240. Widget w;
  1241. char *resource;
  1242. char *value;
  1243. {
  1244. X    Arg a[1];
  1245. X
  1246. X    if (!w) {
  1247. X        fprintf (stderr, "set_something called with w==0\n");
  1248. X        return;
  1249. X    }
  1250. X
  1251. X    XtSetArg (a[0], resource, value);
  1252. X    XtSetValues (w, a, 1);
  1253. }
  1254. X
  1255. /* handy way to get one resource for a widget.
  1256. X * shouldn't use this if you have several things to get for the same widget.
  1257. X */
  1258. get_something (w, resource, value)
  1259. Widget w;
  1260. char *resource;
  1261. char *value;
  1262. {
  1263. X    Arg a[1];
  1264. X
  1265. X    if (!w) {
  1266. X        fprintf (stderr, "get_something called with w==0\n");
  1267. X        exit(1);
  1268. X    }
  1269. X
  1270. X    XtSetArg (a[0], resource, value);
  1271. X    XtGetValues (w, a, 1);
  1272. }
  1273. X
  1274. /* given a widget an XmString resource, set *txtp to an ASCII string of it.
  1275. X * N.B. it appears that *txtp is NOT to be XtFree'd. thus, we remalloc it to be
  1276. X *   sure and so OUR caller should always XtFree (*txtp).
  1277. X */
  1278. get_xmstring (w, resource, txtp)
  1279. Widget w;
  1280. char *resource;
  1281. char **txtp;
  1282. {
  1283. X    char *tmp;
  1284. X
  1285. X    if (!w) {
  1286. X        fprintf (stderr, "get_xmstring called with w==0\n");
  1287. X        tmp = "?w";
  1288. X    } else {
  1289. X        XmString str;
  1290. X        get_something(w, resource, (char *)&str); 
  1291. X        if (!XmStringGetLtoR (str, XmSTRING_DEFAULT_CHARSET, &tmp)) {
  1292. X        /*
  1293. X        fprintf (stderr, "can't get string for %s\n", resource);
  1294. X        */
  1295. X        tmp = "?s";
  1296. X        }
  1297. X        XmStringFree (str);
  1298. X    }
  1299. X    strcpy (*txtp = XtMalloc (strlen(tmp)+1), tmp);
  1300. }
  1301. X
  1302. set_xmstring (w, resource, txt)
  1303. Widget w;
  1304. char *resource;
  1305. char *txt;
  1306. {
  1307. X    XmString str;
  1308. X
  1309. X    if (!w) {
  1310. X        fprintf (stderr, "set_xmstring called with w==0\n");
  1311. X        return;
  1312. X    }
  1313. X
  1314. X    str = XmStringCreateLtoR (txt, XmSTRING_DEFAULT_CHARSET);
  1315. X    set_something (w, resource, str);
  1316. X    XtFree (str);
  1317. }
  1318. X
  1319. static int char_w, char_h;
  1320. X
  1321. char_width()
  1322. {
  1323. X    if (!char_w)
  1324. X        get_char_wh();
  1325. X    return (char_w);
  1326. }
  1327. X
  1328. char_height()
  1329. {
  1330. X    if (!char_h)
  1331. X        get_char_wh();
  1332. X    return (char_h);
  1333. }
  1334. X
  1335. static
  1336. get_char_wh()
  1337. {
  1338. X    static char sample[] = "M";
  1339. X    Widget pb;
  1340. X    XmFontList fl;
  1341. X    XmString str;
  1342. X    Dimension xw, xh;
  1343. X
  1344. X    if (!toplevel_w) {
  1345. X        printf ("called get_char_wh() before making toplevel\n");
  1346. X        exit(1);
  1347. X    }
  1348. X
  1349. X    pb = XtCreateManagedWidget("fontexample", xmPushButtonWidgetClass,
  1350. X                            toplevel_w, (Arg *)0, 0);
  1351. X    get_something (pb, XmNfontList, &fl);
  1352. X
  1353. X    str = XmStringCreateLtoR (sample, XmSTRING_DEFAULT_CHARSET);
  1354. X    XmStringExtent (fl, str, &xw, &xh);
  1355. X    /*
  1356. X    printf ("'%s': xw=%d xh=%d\n", sample, xw, xh);
  1357. X    */
  1358. X    char_w = xw + 1;
  1359. X    char_h = 2*xh;
  1360. X    XmStringFree(str);
  1361. X    XtDestroyWidget (pb);
  1362. }
  1363. X
  1364. /* make a string of width n characters.
  1365. X * N.B. we save these for reuse, so DON'T XmStringFree it!
  1366. X */
  1367. XXmString
  1368. str_width(n)
  1369. int n;
  1370. {
  1371. X    typedef struct {
  1372. X        XmString str;
  1373. X        int n;
  1374. X    } Str;
  1375. X    static Str *strtbl;
  1376. X    static int nstrtbl;
  1377. X    char proto[100];
  1378. X    Str *new;
  1379. X    int i;
  1380. X
  1381. X    if (n > sizeof(proto)-1) {
  1382. X        fprintf (stderr, "str_width request too long\n");
  1383. X        exit(1);
  1384. X    }
  1385. X
  1386. X    /* search existing set first */
  1387. X    for (i = 0; i < nstrtbl; i++)
  1388. X        if (strtbl[i].n == n)
  1389. X        return (strtbl[i].str);
  1390. X
  1391. X    /* not found, so make a new entry */
  1392. X    for (i = 0; i < n; i++)
  1393. X        proto[i] = ' ';
  1394. X    proto[i] = '\0';
  1395. X    strtbl = (Str *) XtRealloc ((char *)strtbl, (nstrtbl+1)*sizeof(Str));
  1396. X    new = &strtbl[nstrtbl++];
  1397. X    new->str = XmStringCreateLtoR (proto, XmSTRING_DEFAULT_CHARSET);
  1398. X    new->n = n;
  1399. X    return (new->str);
  1400. }
  1401. X
  1402. static void
  1403. nyi ()
  1404. {
  1405. X    query (toplevel_w, "Not yet implemeted", "Ok", (char*)0, (char*)0,
  1406. X                (void (*)())0, (void (*)())0, (void (*)())0);
  1407. X
  1408. }
  1409. X
  1410. usage (why)
  1411. char *why;
  1412. {
  1413. X    if (why)
  1414. X        printf ("%s\n", why);
  1415. X    exit (1);
  1416. }
  1417. X
  1418. static void
  1419. m_activate_cb (w, client, call)
  1420. Widget w;
  1421. caddr_t client;
  1422. caddr_t call;
  1423. {
  1424. X    int code = (int)client;
  1425. X
  1426. X    switch (code) {
  1427. X    case QUIT:    exit(0); break;
  1428. X    case DATA:    dm_manage(); break;
  1429. X    case RISET:    rm_manage(); break;
  1430. X    case SEP:    sm_manage(); break;
  1431. X    case JUPMOON:    jm_manage(); break;
  1432. X    case ALTAZ:    aa_manage(); break;
  1433. X    case DOME:    sd_manage(); break;
  1434. X    case SOLARSYS:    ss_manage(); break;
  1435. X    case PLOT:    plot_manage(); break;
  1436. X    case LIST:    lst_manage(); break;
  1437. X    case SEARCH:    srch_manage(); break;
  1438. X    case OBJXY:    obj_manage(); break;
  1439. X    case VERSION:    version(); break;
  1440. X    case REFERENCES:references(); break;
  1441. X    case OPERATION:    operation_help(); break;
  1442. X    case INTRO:    intro(); break;
  1443. X    case MOON:    m_manage(); break;
  1444. X    case CONFIGFILE:config_help(); break;
  1445. X    case DATETIME:    datetime_help(); break;
  1446. X    case NOTES:    notes_help(); break;
  1447. X    default:     printf ("Main menu bug: code=%d\n", code); break;
  1448. X    }
  1449. }
  1450. X
  1451. static
  1452. references()
  1453. {
  1454. X    static char *msg[] = {
  1455. "Many formulas and tables are based, with permission, on material found in",
  1456. "\"Astronomy with your Personal Computer\" by Dr. Peter Duffett-Smith,",
  1457. "Cambridge University Press, (c) 1985."
  1458. };
  1459. X
  1460. X    hlp_dialog ("References", msg, sizeof(msg)/sizeof(msg[0]));
  1461. }
  1462. X
  1463. static
  1464. intro()
  1465. {
  1466. X    static char *msg[] = {
  1467. "Xephem computes all sorts of information about the planets, some moons and",
  1468. "two user defined objects. The program displays this in a variety of tabular",
  1469. "and graphical formats. It can also solve a user defined function built from",
  1470. "this data and save values in plot and listing files for later display.",
  1471. "",
  1472. "Many dialogs have further \"Help\" of their own as well."
  1473. };
  1474. X
  1475. X    hlp_dialog ("Intro", msg, sizeof(msg)/sizeof(msg[0]));
  1476. }
  1477. X
  1478. static
  1479. config_help()
  1480. {
  1481. X    static char *msg[] = {
  1482. "When xephem starts up it looks for a file named ephem.cfg. The name may be",
  1483. "changed with the -c option or the EPHEMCFG environ variable. The file",
  1484. "contains initialization information in the form of keyword=value pairs.",
  1485. "The same keyword=value pairs can be used from the command line as well."
  1486. };
  1487. X
  1488. X    hlp_dialog ("Initialization", msg, sizeof(msg)/sizeof(msg[0]));
  1489. }
  1490. X
  1491. static
  1492. datetime_help()
  1493. {
  1494. X    static char *msg[] = {
  1495. "Dates are mm/dd/yy - you need only specify what changes. Dates can also be",
  1496. "given as decimal years. Times are hh:mm:ss - again, only specify what changes."
  1497. };
  1498. X
  1499. X    hlp_dialog ("Date/time", msg, sizeof(msg)/sizeof(msg[0]));
  1500. }
  1501. X
  1502. static
  1503. operation_help()
  1504. {
  1505. X    static char *msg[] = {
  1506. "Set location details, starting date and time, step size and number of steps,",
  1507. "select desired views, then select \"Update\" to run.",
  1508. };
  1509. X
  1510. X    hlp_dialog ("Operation", msg, sizeof(msg)/sizeof(msg[0]));
  1511. }
  1512. X
  1513. static
  1514. notes_help()
  1515. {
  1516. X    static char *msg[] = {
  1517. "floating point errors are not trapped gracefully. especially be careful not",
  1518. "  to turn on Objx/y before they are properly defined.",
  1519. "",
  1520. "planet magnitudes are not very accurate."
  1521. };
  1522. X
  1523. X    hlp_dialog ("Notes", msg, sizeof(msg)/sizeof(msg[0]));
  1524. }
  1525. SHAR_EOF
  1526. chmod 0644 xephem.c ||
  1527. echo 'restore of xephem.c failed'
  1528. Wc_c="`wc -c < 'xephem.c'`"
  1529. test 20532 -eq "$Wc_c" ||
  1530.     echo 'xephem.c: original size 20532, current size' "$Wc_c"
  1531. rm -f _shar_wnt_.tmp
  1532. fi
  1533. # ============= astro.h ==============
  1534. if test -f 'astro.h' -a X"$1" != X"-c"; then
  1535.     echo 'x - skipping astro.h (File already exists)'
  1536.     rm -f _shar_wnt_.tmp
  1537. else
  1538. > _shar_wnt_.tmp
  1539. echo 'x - extracting astro.h (Text)'
  1540. sed 's/^X//' << 'SHAR_EOF' > 'astro.h' &&
  1541. #ifndef PI
  1542. #define    PI        3.141592653589793
  1543. #endif
  1544. X
  1545. /* conversions among hours (of ra), degrees and radians. */
  1546. #define    degrad(x)    ((x)*PI/180.)
  1547. #define    raddeg(x)    ((x)*180./PI)
  1548. #define    hrdeg(x)    ((x)*15.)
  1549. #define    deghr(x)    ((x)/15.)
  1550. #define    hrrad(x)    degrad(hrdeg(x))
  1551. #define    radhr(x)    deghr(raddeg(x))
  1552. X
  1553. /* ratio of from synodic (solar) to sidereal (stellar) rate */
  1554. #define    SIDRATE        .9972695677
  1555. X
  1556. /* manifest names for planets.
  1557. X * N.B. must cooincide with usage in pelement.c and plans.c.
  1558. X */
  1559. #define    MERCURY    0
  1560. #define    VENUS    1
  1561. #define    MARS    2
  1562. #define    JUPITER    3
  1563. #define    SATURN    4
  1564. #define    URANUS    5
  1565. #define    NEPTUNE    6
  1566. #define    PLUTO    7
  1567. SHAR_EOF
  1568. chmod 0644 astro.h ||
  1569. echo 'restore of astro.h failed'
  1570. Wc_c="`wc -c < 'astro.h'`"
  1571. test 620 -eq "$Wc_c" ||
  1572.     echo 'astro.h: original size 620, current size' "$Wc_c"
  1573. rm -f _shar_wnt_.tmp
  1574. fi
  1575. # ============= circum.h ==============
  1576. if test -f 'circum.h' -a X"$1" != X"-c"; then
  1577.     echo 'x - skipping circum.h (File already exists)'
  1578.     rm -f _shar_wnt_.tmp
  1579. else
  1580. > _shar_wnt_.tmp
  1581. echo 'x - extracting circum.h (Text)'
  1582. sed 's/^X//' << 'SHAR_EOF' > 'circum.h' &&
  1583. #define    SPD    (24.0*3600.0)    /* seconds per day */
  1584. X
  1585. #define    EOD    (-9786)        /* special epoch flag: use epoch of date */
  1586. #define    RTC    (-1324)        /* special tminc flag: use rt clock */
  1587. #define    NOMJD    (-58631.)    /* an unlikely mjd for initing static mjd's */
  1588. #define    NOHELIO    (-2314)        /* special s_hlong flag: means it and s_hlat are
  1589. X                 * undefined
  1590. X                 */
  1591. X
  1592. #define    STDHZN        0    /* rise/set times based on nominal conditions */
  1593. #define    ADPHZN        1    /* rise/set times based on exact current " */
  1594. #define    TWILIGHT    2    /* rise/set times for sun 18 degs below hor */
  1595. X
  1596. /* info about our local observing circumstances */
  1597. typedef struct {
  1598. X    double n_mjd;    /* modified Julian date, ie, days since
  1599. X             * Jan 0.5 1900 (== 12 noon, Dec 30, 1899), utc.
  1600. X             * enough precision to get well better than 1 second.
  1601. X             * N.B. if not first member, must move NOMJD inits.
  1602. X             */
  1603. X    double n_lat;    /* latitude, >0 north, rads */
  1604. X    double n_lng;    /* longitude, >0 east, rads */
  1605. X    double n_tz;    /* time zone, hrs behind UTC */
  1606. X    double n_temp;    /* atmospheric temp, degrees C */
  1607. X    double n_pressure; /* atmospheric pressure, mBar */
  1608. X    double n_height;    /* height above sea level, earth radii */
  1609. X    double n_epoch;    /* desired precession display epoch as an mjd, or EOD */
  1610. X    char n_tznm[4];    /* time zone name; 3 chars or less, always 0 at end */
  1611. } Now;
  1612. extern double    mjd_day(), mjd_hr();
  1613. X
  1614. /* info about where and how we see something in the sky */
  1615. typedef struct {
  1616. X    double s_ra;    /* ra, rads (precessed to n_epoch) */
  1617. X    double s_dec;    /* dec, rads (precessed to n_epoch) */
  1618. X    double s_az;    /* azimuth, >0 e of n, rads */
  1619. X    double s_alt;    /* altitude above topocentric horizon, rads */
  1620. X    double s_sdist;    /* dist from object to sun, au */
  1621. X    double s_edist;    /* dist from object to earth, au */
  1622. X    double s_elong;    /* angular sep between object and sun, >0 if east */
  1623. X    double s_hlong;    /* heliocentric longitude, rads */
  1624. X    double s_hlat;    /* heliocentric latitude, rads */
  1625. X    double s_size;    /* angular size, arc secs */
  1626. X    double s_phase;    /* phase, % */
  1627. X    double s_mag;    /* visual magnitude */
  1628. } Sky;
  1629. X
  1630. /* flags for riset_cir() status */
  1631. #define    RS_NORISE    0x001    /* object does not rise as such today */
  1632. #define    RS_2RISES    0x002    /* object rises more than once today */
  1633. #define    RS_NOSET    0x004    /* object does not set as such today */
  1634. #define    RS_2SETS    0x008    /* object sets more than once today */
  1635. #define    RS_CIRCUMPOLAR    0x010    /* object stays up all day today */
  1636. #define    RS_2TRANS    0x020    /* transits twice in one day */
  1637. #define    RS_NEVERUP    0x040    /* object never rises today */
  1638. #define    RS_NOTRANS    0x080    /* doesn't transit today */
  1639. #define    RS_ERROR    0x100    /* can't figure out times... */
  1640. X
  1641. /* shorthands for fields a Now pointer, np */
  1642. #define mjd    np->n_mjd
  1643. #define lat    np->n_lat
  1644. #define lng    np->n_lng
  1645. #define tz    np->n_tz
  1646. #define temp    np->n_temp
  1647. #define pressure np->n_pressure
  1648. #define height    np->n_height
  1649. #define epoch    np->n_epoch
  1650. #define tznm    np->n_tznm
  1651. SHAR_EOF
  1652. chmod 0644 circum.h ||
  1653. echo 'restore of circum.h failed'
  1654. Wc_c="`wc -c < 'circum.h'`"
  1655. test 2856 -eq "$Wc_c" ||
  1656.     echo 'circum.h: original size 2856, current size' "$Wc_c"
  1657. rm -f _shar_wnt_.tmp
  1658. fi
  1659. # ============= fieldmap.h ==============
  1660. if test -f 'fieldmap.h' -a X"$1" != X"-c"; then
  1661.     echo 'x - skipping fieldmap.h (File already exists)'
  1662.     rm -f _shar_wnt_.tmp
  1663. else
  1664. > _shar_wnt_.tmp
  1665. echo 'x - extracting fieldmap.h (Text)'
  1666. sed 's/^X//' << 'SHAR_EOF' > 'fieldmap.h' &&
  1667. /* info about a "Field Map".
  1668. X * this is what we use to keep track of each of the oodles of pushbuttons.
  1669. X * we store an id (unique only within a given menu), flags as to how the
  1670. X * button can be used, field width (for initial button creation) and the
  1671. X * Widget of the button, once it is managed, for subsequent control.
  1672. X */
  1673. typedef struct {
  1674. X    int id;        /* field id; managed by mkid/xpos/ypos */
  1675. X    int how;    /* whether field is CHG and/or PLT */
  1676. X    int width;    /* button width (chars) */
  1677. X    char *prompt;    /* prompt, or label string if !how */
  1678. X    char *name;    /* name it goes by in search equations, etc */
  1679. X    Widget w;    /* field's pushbutton widget id */
  1680. } FieldMap;
  1681. X
  1682. #define    CHG        0x1    /* field may be picked for operator changing */
  1683. #define    PLT        0x2    /* may be picked for plotting/listing/srching */
  1684. X
  1685. /* convert a row and col into an id and back.
  1686. X * [xy]pos generate a permillage location.
  1687. X * N.B. NR and NC must be defined in .c before using these.
  1688. X */
  1689. #define    mkid(r,c)    (((r) << 8) | (c))
  1690. #define    f2r(f)        ((f) >> 8)
  1691. #define    f2c(f)        ((f) & 0xff)
  1692. #define    r2ypos(r)    (1000*((r)-1)/NR)
  1693. #define    c2xpos(c)    (1000*((c)-1)/NC)
  1694. #define    xpos(f)        c2xpos(f2c(f))
  1695. #define    ypos(f)        r2ypos(f2r(f))
  1696. SHAR_EOF
  1697. chmod 0644 fieldmap.h ||
  1698. echo 'restore of fieldmap.h failed'
  1699. Wc_c="`wc -c < 'fieldmap.h'`"
  1700. test 1165 -eq "$Wc_c" ||
  1701.     echo 'fieldmap.h: original size 1165, current size' "$Wc_c"
  1702. rm -f _shar_wnt_.tmp
  1703. fi
  1704. # ============= moreobjs.h ==============
  1705. if test -f 'moreobjs.h' -a X"$1" != X"-c"; then
  1706.     echo 'x - skipping moreobjs.h (File already exists)'
  1707.     rm -f _shar_wnt_.tmp
  1708. else
  1709. > _shar_wnt_.tmp
  1710. echo 'x - extracting moreobjs.h (Text)'
  1711. sed 's/^X//' << 'SHAR_EOF' > 'moreobjs.h' &&
  1712. /* additions to the planet defines from astro.h.
  1713. X * must not conflict, and must fit in range 0..15.
  1714. X */
  1715. #define    SUN    (PLUTO+1)
  1716. #define    MOON    (PLUTO+2)
  1717. #define    OBJX    (PLUTO+3)    /* the user-defined object */
  1718. #define    OBJY    (PLUTO+4)    /* the user-defined object */
  1719. #define    NOBJ    (OBJY+1)    /* total number of objects */
  1720. SHAR_EOF
  1721. chmod 0644 moreobjs.h ||
  1722. echo 'restore of moreobjs.h failed'
  1723. Wc_c="`wc -c < 'moreobjs.h'`"
  1724. test 307 -eq "$Wc_c" ||
  1725.     echo 'moreobjs.h: original size 307, current size' "$Wc_c"
  1726. rm -f _shar_wnt_.tmp
  1727. fi
  1728. # ============= patchlevel.h ==============
  1729. if test -f 'patchlevel.h' -a X"$1" != X"-c"; then
  1730.     echo 'x - skipping patchlevel.h (File already exists)'
  1731.     rm -f _shar_wnt_.tmp
  1732. else
  1733. > _shar_wnt_.tmp
  1734. echo 'x - extracting patchlevel.h (Text)'
  1735. sed 's/^X//' << 'SHAR_EOF' > 'patchlevel.h' &&
  1736. /* the following is a separate number that will be incremented after each
  1737. SHAR_EOF
  1738. true || echo 'restore of patchlevel.h failed'
  1739. fi
  1740. echo 'End of  part 11'
  1741. echo 'File patchlevel.h is continued in part 12'
  1742. echo 12 > _shar_seq_.tmp
  1743. exit 0
  1744. -- 
  1745. --
  1746. Molecular Simulations, Inc.            mail: dcmartin@msi.com
  1747. 796 N. Pastoria Avenue                uucp: uunet!dcmartin
  1748. Sunnyvale, California 94086            at&t: 408/522-9236
  1749.