home *** CD-ROM | disk | FTP | other *** search
Text File | 1993-05-15 | 30.9 KB | 1,001 lines |
- /* code to manage the stuff on the sky view display.
- * the filter menu is in filtermenu.c.
- */
-
- #include <stdio.h>
- #include <ctype.h>
- #include <math.h>
- #if defined(__STDC__)
- #include <stdlib.h>
- #endif
- #include <X11/Xlib.h>
- #include <Xm/Xm.h>
- #include <Xm/Form.h>
- #include <Xm/Frame.h>
- #include <Xm/DrawingA.h>
- #include <Xm/Label.h>
- #include <Xm/PushB.h>
- #include <Xm/CascadeB.h>
- #include <Xm/RowColumn.h>
- #include <Xm/ToggleB.h>
- #include <Xm/Text.h>
- #include <Xm/Scale.h>
- #include <Xm/Separator.h>
- #include "astro.h"
- #include "circum.h"
-
- /* we keep a linked-list of Objects we want trails for. these in turn "contain"
- * a variable-length array of TSkys for each location in the trail. The TSkys
- * are kept in increasing-time order as they are inserted for later plotting.
- * an item is added when the popup says so; it is removed if we are told the
- * object has been changed via sv_newobj(); all are removed if the whole db
- * changes.
- * also, we add to sky[] in multiples of TRAILCHUNKS for memory efficiency.
- */
- typedef struct {
- unsigned flags; /* OBJF_ things for this particular point */
- double ts_mjd; /* mjd when this Obj was valid */
- Obj o; /* copy of the object at ts_mjd */
- } TSky;
- struct trailObj {
- struct trailObj *ntop; /* pointer to next, or NULL */
- int on; /* use to mark on/off; actually remved on next update */
- Obj *op; /* object being trailed */
- int nsky; /* number of items in use within sky[] */
- int nskymem; /* total space of sky[] */
- TSky sky[1]; /* basicaly a variable-length array of Objs */
- };
- typedef struct trailObj TrailObj;
-
- #if defined(__STDC__) || defined(__cplusplus)
- #define P_(s) s
- #else
- #define P_(s) ()
- #endif
-
- extern Now *mm_get_now P_((void));
- extern Obj *db_basic P_((int id));
- extern Obj *db_next P_((Obj *op, HowNext how));
- extern char *obj_description P_((Obj *op));
- extern double mjd_hr P_((double jd));
- extern int f_ison P_((void));
- extern int lc P_((int cx, int cy, int cw, int x1, int y1, int x2, int y2, int *sx1, int *sy1, int *sx2, int *sy2));
- extern int svf_filter_ok P_((Obj *op));
- extern int tickmarks P_((double min, double max, int numdiv, double ticks[]));
- extern void aa_hadec P_((double lati, double alt, double az, double *ha, double *dec));
- extern void db_update P_((Obj *op));
- extern void ecl_eq P_((double Mjd, double Lat, double Lng, double *ra, double *dec));
- extern void eq_ecl P_((double Mjd, double ra, double dec, double *Lat, double *Lng));
- extern void f_showit P_((Widget w, char *s));
- extern void fs_angle P_((char out[], double a));
- extern void fs_date P_((char out[], double jd));
- extern void fs_ra P_((char out[], double ra));
- extern void fs_time P_((char out[], double t));
- extern void get_something P_((Widget w, char *resource, char *value));
- extern void gk_mag P_((double g, double k, double rp, double rho, double *mp));
- extern void hadec_aa P_((double lati, double ha, double dec, double *alt, double *az));
- extern void hlp_dialog P_((char *tag, char *deflt[], int ndeflt));
- extern void now_lst P_((Now *np, double *lst));
- extern void obj_pickgc P_((Obj *op, Widget w, GC *gcp));
- extern void obj_set P_((Obj *op));
- extern void precess P_((double mjd1, double mjd2, double *ra, double *dec));
- extern void range P_((double *v, double r));
- extern void refract P_((double pr, double tr, double ta, double *aa));
- extern void set_something P_((Widget w, char *resource, char *value));
- extern void set_xmstring P_((Widget w, char *resource, char *txt));
- extern void svf_create P_((void));
- extern void svf_manage P_((void));
- extern void svf_manage_toggle P_((void));
- extern void svf_unmanage P_((void));
- extern void timestamp P_((Now *np, Widget w));
- extern void unrefract P_((double pr, double tr, double aa, double *ta));
- extern void watch_cursor P_((int want));
- extern void xe_msg P_((char *msg, int app_modal));
-
- void sv_manage P_((void));
- int sv_ison P_((void));
- void sv_newobj P_((int dbidx));
- void sv_newdb P_((int appended));
- void sv_update P_((Now *np, int how_much));
- void sv_point P_((Obj *op));
- int sv_id P_((Obj *op));
- void sv_cursor P_((Cursor c));
- void sv_all P_((Now *np, int preclr));
- void sv_draw_obj P_((Display *dsp, Drawable win, GC gc, Obj *op, int x, int y, int diam, int dotsonly));
- static void sv_copy_sky P_((void));
- static void sv_create_svform P_((void));
- static void sv_create_find P_((Widget parent));
- static void sv_close_cb P_((Widget w, XtPointer client, XtPointer call));
- static void sv_help_cb P_((Widget w, XtPointer client, XtPointer call));
- static void sv_aa_cb P_((Widget w, XtPointer client, XtPointer call));
- static void sv_all_labels_cb P_((Widget w, XtPointer client, XtPointer call));
- static void sv_filter_cb P_((Widget w, XtPointer client, XtPointer call));
- static void sv_grid_cb P_((Widget w, XtPointer client, XtPointer call));
- static void sv_set_scales P_((void));
- static void sv_da_exp_cb P_((Widget w, XtPointer client, XtPointer call));
- static void sv_da_input_cb P_((Widget w, XtPointer client, XtPointer call));
- static void sv_da_motion_cb P_((Widget w, XtPointer client, XEvent *ev, Boolean *continue_to_dispatch));
- static void sv_changed_cb P_((Widget w, XtPointer client, XtPointer call));
- static void sv_ecliptic_cb P_((Widget w, XtPointer client, XtPointer call));
- static void sv_justdots_cb P_((Widget w, XtPointer client, XtPointer call));
- static void sv_finding_cb P_((Widget wid, XtPointer client, XtPointer call));
- static void sv_find_cb P_((Widget w, XtPointer client, XtPointer call));
- static void sv_magdrag_cb P_((Widget w, XtPointer client, XtPointer call));
- static void sv_set_view P_((void));
- static void sv_getcircle P_((unsigned int *wp, unsigned int *hp, unsigned int *rp, unsigned int *xbp, unsigned int *ybp));
- static void sv_popup P_((XEvent *ev, Obj *op, TSky *tsp));
- static void sv_create_popup P_((void));
- static void sv_pu_activate_cb P_((Widget w, XtPointer client, XtPointer call));
- static void sv_pu_trail_cb P_((Widget wid, XtPointer client, XtPointer call));
- static void sv_pu_label_cb P_((Widget wid, XtPointer client, XtPointer call));
- static void tobj_rmoff P_((void));
- static void tobj_rmobj P_((Obj *op));
- static TrailObj *tobj_addobj P_((Obj *op));
- static TrailObj *tobj_growsky P_((TrailObj *top));
- static void tobj_reset P_((void));
- static TrailObj *tobj_find P_((Obj *op));
- static TrailObj *tobj_addsky P_((TrailObj *top, double jd, Obj *op));
- static void tobj_display_all P_((unsigned r, unsigned xb, unsigned yb));
- static sv_dbobjloc P_((Obj *op, int r, int *xp, int *yp));
- static sv_trailobjloc P_((TSky *tsp, int r, int *xp, int *yp));
- static sv_precheck P_((Obj *op));
- static sv_bright_ok P_((Obj *op));
- static sv_infov P_((Obj *op));
- static sv_loc P_((int rad, double altdec, double azra, int *xp, int *yp));
- static sv_unloc P_((int rad, int x, int y, double *altdecp, double *azrap));
- static void draw_ecliptic P_((Display *dsp, Window win, GC gc, unsigned int r, unsigned int xb, unsigned int yb));
- static void draw_grid P_((Display *dsp, Window win, GC gc, unsigned int r, unsigned int xb, unsigned int yb));
- static magdiam P_((double m));
- static void sv_mk_gcs P_((Display *dsp, Window win));
- static void draw_label P_((Display *dsp, Window win, GC gc, char label[], int x, int y));
-
- #undef P_
-
- extern Widget toplevel_w;
-
- #define NGRID 20 /* max grid lines each dimension */
- #define NSEGS 5 /* piecewise segments per arc */
- #define ECL_TICS 2 /* period of points for ecliptic, pixels */
-
- #define MARKER 20 /* pointer marker half-width, pixels */
-
- #define BMAGLIMIT (-28) /* brightest setting for the Mag scales */
- #define FMAGLIMIT 20 /* faintest setting for the Mag scales */
- #define TRAILCHUNKS 50 /* we malloc these many at a time */
-
- static Widget svform_w; /* main sky view form dialog */
- static Widget svda_w; /* sky view drawing area */
- static Widget fov_w, altdec_w, azra_w; /* scale widgets */
- static Widget fmag_w, bmag_w; /* magnitude scale widgets */
- static Widget hgrid_w, vgrid_w; /* h and v grid spacing labels */
- static Widget aa_w, rad_w; /* altaz/radec toggle buttons */
- static Widget dt_w; /* the date/time stamp label widget */
- static Widget find_w[2]; /* cascade buttons for "find" objx/y */
- static Pixmap sv_pm; /* off-screen pixmap we *really* draw */
- static Widget talt_w, taz_w; /* tracking alt/az report widgets */
- static Widget tra_w, tdec_w; /* tracking ra/dec report widgets */
-
- /* pixels and GCs
- */
- static Pixel fg_p, bg_p, sky_p; /* default fg, background, and sky colors */
- static GC sv_gc; /* the default GC */
-
- static int aa_mode = -1; /* 1 for alt/az or 0 for ra/dec */
- static double sv_altdec; /* view center alt or dec, rads */
- static double sv_azra; /* view center az or ra, rads */
- static double sv_fov; /* field of view, rads */
- static int fmag, bmag; /* faintest/brightest magnitude to display */
- static int justdots; /* set when only want to use dots on the map */
- static int want_ecliptic; /* set when want to see the ecliptic */
- static TrailObj *trailobj; /* head of a malloced linked-list -- 0 when
- * empty
- */
- static int want_grid; /* set when we want to draw the coord grid */
- static all_labels; /* !0 when want to display all labels */
- static int sv_ournewobj; /* used to inhibit useless redrawing */
-
- static char null_grid_str[] = " ";
-
- /* info about the popup widget.
- * we make one once and keep reusing it -- seems to be a bit faster that way.
- */
- typedef struct {
- Widget pu_w;
- Widget name_w;
- Widget desc_w;
- Widget spect_w;
- Widget ud_w;
- Widget ut_w;
- Widget ra_w;
- Widget dec_w;
- Widget alt_w;
- Widget az_w;
- Widget mag_w;
- Widget trail_w;
- Widget label_w;
- Obj *op;
- TSky *tsp; /* this is used if we are displaying a trailed object */
- } Popup;
- static Popup pu;
-
- enum {AIM, MK_OBJX}; /* popup button activate codes */
-
- /* Obj.flags or TSky flags values */
- #define OBJF_ONSCREEN 0x1 /* bit set if obj is on screen */
- #define OBJF_LABEL 0x2 /* set if label is to be on */
-
- /* called when the sky view is activated via the main menu pulldown.
- * if never called before, create and manage all the widgets as a child of a
- * form. otherwise, just toggle whether the form is managed.
- * also manage the corresponding filter dialog along with.
- * freeing the pixmap will force a fresh update on the next expose.
- */
- void
- sv_manage ()
- {
- if (!svform_w)
- sv_create_svform(); /* also creates the filter */
-
- if (XtIsManaged(svform_w)) {
- XtUnmanageChild (svform_w);
- svf_unmanage();
- if (sv_pm) {
- XFreePixmap (XtDisplay(svda_w), sv_pm);
- sv_pm = (Pixmap) NULL;
- }
- } else {
- XtManageChild (svform_w);
- /* rely on expose to a fresh update */
- }
- }
-
- sv_ison()
- {
- return (svform_w && XtIsManaged(svform_w));
- }
-
- /* called when a user-defined object has changed.
- * take it off the trailobj list, if it's there (it's ok if it's not).
- * then since we rely on knowing our update will be called we need do nothing
- * more to redisplay without the object.
- */
- void
- sv_newobj(dbidx)
- int dbidx; /* OBJX or OBJY */
- {
- Obj *op = db_basic(dbidx);
-
- tobj_rmobj (op);
-
- }
-
- /* called when the db (beyond NOBJ) has changed.
- * if it was appended to we can just redraw; if it was changed we need to
- * discard any trails we are keeping first.
- */
- void
- sv_newdb(appended)
- int appended;
- {
- if (!appended)
- tobj_reset();
- sv_update (mm_get_now(), 1);
- }
-
- /* called when we are to update our view.
- * don't bother if we are unmanaged unless there are trails to be saved.
- * add any objects in the trails list then redraw the screen if we are up.
- * also don't bother if we are the reason for an all_newobj() or if fields are
- * off.
- * we also remove any trails that have been turned off.
- */
- /* ARGSUSED */
- void
- sv_update (np, how_much)
- Now *np;
- int how_much;
- {
- TrailObj *top;
- int up;
-
- if (sv_ournewobj)
- return;
-
- up = svform_w && XtIsManaged(svform_w);
- if (!up && !trailobj)
- return;
-
- /* remove trails no longer wanted. */
- tobj_rmoff();
-
- /* add an entry to each trailed object for this time. */
- for (top = trailobj; top; top = top->ntop) {
- db_update (top->op);
- top = tobj_addsky (top, mjd, top->op);
- }
-
- if (up && f_ison())
- sv_all(np, 1);
- }
-
- /* point at the given object and mark it.
- * N.B. we do *not* update the s_ fields of op.
- */
- void
- sv_point (op)
- Obj *op;
- {
- double d;
-
- if (!svform_w || !op || op->type == UNDEFOBJ)
- return;
-
- if (aa_mode && op->s_alt < 0.0) {
- xe_msg ("Object is below the horizon", 1);
- return;
- }
-
- d = raddeg(aa_mode ? op->s_alt : op->s_dec);
- XmScaleSetValue (altdec_w, (int)floor(d + 0.5));
- d = aa_mode ? raddeg(op->s_az) : 10.0*radhr(op->s_ra);
- XmScaleSetValue (azra_w, (int)floor(d + 0.5));
- sv_set_view();
- sv_all(mm_get_now(), 1);
-
- switch (sv_id(op)) {
- case -1: xe_msg ("sv_point: object is below horizon", 0); break;
- case -2: xe_msg ("sv_point: object is outside FOV", 0); break;
- }
- }
-
- /* show a marker at the location of the given object.
- * return 0 if object was in fact in the field of view;
- * -1 if in alt/az mode and op is below the horizon now;
- * -2 if object is otherwise outside the field of view now.
- * N.B. we do *not* update the s_ fields of op.
- */
- sv_id (op)
- Obj *op;
- {
- Display *dsp = XtDisplay (svda_w);
- Window win = XtWindow (svda_w);
- unsigned int wide, h, r, xb, yb;
- double altdec, azra;
- int x, y;
-
- if (!svform_w || !XtIsManaged(svform_w) || !op || op->type == UNDEFOBJ)
- return (-2);
-
- sv_getcircle (&wide, &h, &r, &xb, &yb);
-
- altdec = aa_mode ? op->s_alt : op->s_dec;
- azra = aa_mode ? op->s_az : op->s_ra;
- if (!sv_loc (r, altdec, azra, &x, &y))
- return (aa_mode && op->s_alt < 0.0 ? -1 : -2);
-
- x += xb;
- y += yb;
-
- XSetForeground (dsp, sv_gc, fg_p);
- XDrawLine (dsp, win, sv_gc, x-MARKER, y-MARKER, x+MARKER, y+MARKER);
- XDrawLine (dsp, win, sv_gc, x+MARKER, y-MARKER, x-MARKER, y+MARKER);
-
- return (0);
- }
-
- /* called to put up or remove the watch cursor. */
- void
- sv_cursor (c)
- Cursor c;
- {
- Window win;
-
- if (svform_w && (win = XtWindow(svform_w))) {
- Display *dsp = XtDisplay(svform_w);
- if (c)
- XDefineCursor (dsp, win, c);
- else
- XUndefineCursor (dsp, win);
- }
- }
-
- /* draw everything subject to any filtering.
- */
- /* ARGSUSED */
- void
- sv_all(np, preclr)
- Now *np;
- int preclr;
- {
- Display *dsp = XtDisplay(svda_w);
- Window win = sv_pm;
- unsigned int w, h, r, xb, yb;
- Obj *op;
-
- watch_cursor(1);
-
- /* put up the timestamp */
- timestamp (np, dt_w);
-
- sv_getcircle (&w, &h, &r, &xb, &yb);
-
- /* rebuild the clean circle */
- XSetForeground (dsp, sv_gc, bg_p);
- XFillRectangle (dsp, win, sv_gc, 0, 0, w, h);
- XSetForeground (dsp, sv_gc, sky_p);
- XFillArc (dsp, win, sv_gc, xb+1, yb+1, 2*r-2, 2*r-2, 0, 360*64);
- XSetForeground (dsp, sv_gc, fg_p);
- XDrawArc (dsp, win, sv_gc, xb, yb, 2*r-1, 2*r-1, 0, 360*64);
-
- /* go through the database and display what we want */
- for (op = db_next(NULL, OBJS_ALL); op; op = db_next(op, OBJS_ALL)) {
- GC gc;
- int x, y;
- obj_pickgc(op, svda_w, &gc);
- if (!sv_dbobjloc(op, r, &x, &y))
- op->o_flags &= ~OBJF_ONSCREEN;
- else {
- /* yup, it's really supposed to be on the screen */
- db_update (op);
- x += xb;
- y += yb;
- sv_draw_obj (dsp, win, gc, op, x, y,
- magdiam(op->s_mag/MAGSCALE), justdots);
- op->o_flags |= OBJF_ONSCREEN;
- if (all_labels || (op->o_flags & OBJF_LABEL))
- draw_label (dsp, win, gc, op->o_name, x, y);
- }
- }
-
- sv_draw_obj (dsp, win, (GC)0, NULL, 0, 0, 0, 0); /* flush */
-
- /* go through the trailobj list and display that stuff too. */
- tobj_display_all(r, xb, yb);
-
- /* draw a grid on top if desired */
- if (want_grid) {
- XSetForeground (dsp, sv_gc, fg_p);
- draw_grid(dsp, win, sv_gc, r, xb, yb);
- }
-
- /* and finally draw the ecliptic on top if desired */
- if (want_ecliptic) {
- XSetForeground (dsp, sv_gc, fg_p);
- draw_ecliptic (dsp, win, sv_gc, r, xb, yb);
- }
-
- /* and we're done */
- sv_copy_sky();
-
- watch_cursor(0);
- }
-
- /* draw the given object so it has a nominal diameter of diam pixels.
- * we maintain a static cache of common X drawing objects for efficiency.
- * (mallocing seemed to keep the memory arena too fragmented).
- * to force a flush, call with op == NULL.
- */
- void
- sv_draw_obj (dsp, win, gc, op, x, y, diam, dotsonly)
- Display *dsp;
- Drawable win;
- GC gc;
- Obj *op;
- int x, y;
- int diam;
- int dotsonly;
- {
- #define CACHE_SZ 100
- #define CACHE_PAD 10 /* most we ever need in one call */
- #define CACHE_HWM (CACHE_SZ - CACHE_PAD) /* hi water mark */
- static XPoint xpoints[CACHE_SZ], *xp = xpoints;
- static XArc xdrawarcs[CACHE_SZ], *xda = xdrawarcs;
- static XArc xfillarcs[CACHE_SZ], *xfa = xfillarcs;
- static XSegment xsegments[CACHE_SZ], *xs = xsegments;
- static GC cache_gc;
- int force;
- int t;
-
- /* for sure if no op or different gc */
- force = !op || gc != cache_gc;
-
- if (force || xp >= xpoints + CACHE_HWM) {
- int n;
- if ((n = xp - xpoints) > 0) {
- XDrawPoints (dsp, win, cache_gc, xpoints, n, CoordModeOrigin);
- xp = xpoints;
- #ifdef SVTRACE
- printf ("points=%d\n", n);
- #endif
- }
- }
- if (force || xda >= xdrawarcs + CACHE_HWM) {
- int n;
- if ((n = xda - xdrawarcs) > 0) {
- XDrawArcs (dsp, win, cache_gc, xdrawarcs, n);
- xda = xdrawarcs;
- #ifdef SVTRACE
- printf ("drawarcs=%d\n", n);
- #endif
- }
- }
- if (force || xfa >= xfillarcs + CACHE_HWM) {
- int n;
- if ((n = xfa - xfillarcs) > 0) {
- XFillArcs (dsp, win, cache_gc, xfillarcs, n);
- xfa = xfillarcs;
- #ifdef SVTRACE
- printf ("fillarcs=%d\b", n);
- #endif
- }
- }
- if (force || xs >= xsegments + CACHE_HWM) {
- int n;
- if ((n = xs - xsegments) > 0) {
- XDrawSegments (dsp, win, cache_gc, xsegments, n);
- xs = xsegments;
- #ifdef SVTRACE
- printf ("segments=%d\n", n);
- #endif
- }
- }
-
- cache_gc = gc;
-
- if (!op)
- return; /* just flushing, thanks */
-
- /* one-pixel wide anything is just a dot */
- if (diam <= 1) {
- xp->x = x;
- xp->y = y;
- xp++;
- return;
- }
-
- /* if dotsonly is on don't use the fancy symbols, just use dots */
- if (dotsonly) {
- xfa->x = x - diam/2;
- xfa->y = y - diam/2;
- xfa->width = diam;
- xfa->height = diam;
- xfa->angle1 = 0;
- xfa->angle2 = 360*64;
- xfa++;
- return;
- }
-
- switch (op->type) {
- case PLANET:
- /* filled circle */
- xfa->x = x - diam/2;
- xfa->y = y - diam/2;
- xfa->width = diam;
- xfa->height = diam;
- xfa->angle1 = 0;
- xfa->angle2 = 360*64;
- xfa++;
- break;
- case FIXED:
- switch (op->f_class) {
- case 'G': case 'H': case 'A': /* galaxy */
- /* filled ellipse */
- xfa->x = x - diam/2;
- xfa->y = y - diam/4;
- xfa->width = diam;
- xfa->height = diam/2;
- xfa->angle1 = 0;
- xfa->angle2 = 360*64;
- xfa++;
- break;
- case 'C': case 'U': /* globular clusters */
- /* same as cluster but with a central dot */
- xfa->x = x - 1;
- xfa->y = y - 1;
- xfa->width = 3;
- xfa->height = 3;
- xfa->angle1 = 0;
- xfa->angle2 = 360*64;
- xfa++;
- /* fall through */
- case 'O': /* open cluster */
- /* open circle of dots */
- xp->x = x; xp->y = y-3; xp++;
- xp->x = x+3; xp->y = y-1; xp++;
- xp->x = x+3; xp->y = y+1; xp++;
- xp->x = x; xp->y = y+3; xp++;
- xp->x = x-3; xp->y = y+1; xp++;
- xp->x = x-3; xp->y = y-1; xp++;
- break;
- case 'P': /* planetary nebula */
- /* open ellipse */
- xda->x = x - diam/2;
- xda->y = y - diam/4;
- xda->width = diam;
- xda->height = diam/2;
- xda->angle1 = 0;
- xda->angle2 = 360*64;
- xda++;
- break;
- case 'S': /* stars */
- /* filled circle */
- xfa->x = x - diam/2;
- xfa->y = y - diam/2;
- xfa->width = diam;
- xfa->height = diam;
- xfa->angle1 = 0;
- xfa->angle2 = 360*64;
- xfa++;
- break;
- case 'B': case 'D': /* binary and double stars */
- /* filled circle with one horizontal line through it */
- xfa->x = x - diam/2;
- xfa->y = y - diam/2;
- xfa->width = diam;
- xfa->height = diam;
- xfa->angle1 = 0;
- xfa->angle2 = 360*64;
- xfa++;
- t = 3*diam/4;
- xs->x1 = x - t;
- xs->y1 = y;
- xs->x2 = x + t;
- xs->y2 = y;
- xs++;
- break;
- case 'M': /* multiple stars */
- /* filled circle with two horizontal lines through it */
- xfa->x = x - diam/2;
- xfa->y = y - diam/2;
- xfa->width = diam;
- xfa->height = diam;
- xfa->angle1 = 0;
- xfa->angle2 = 360*64;
- xfa++;
- t = 3*diam/4;
- xs->x1 = x - t;
- xs->y1 = y - diam/6;
- xs->x2 = x + t;
- xs->y2 = y - diam/6;
- xs++;
- xs->x1 = x - t;
- xs->y1 = y + diam/6;
- xs->x2 = x + t;
- xs->y2 = y + diam/6;
- xs++;
- break;
- case 'V': /* variable star */
- /* central dot with concentric circle */
- xfa->x = x - diam/4;
- xfa->y = y - diam/4;
- xfa->width = diam/2;
- xfa->height = diam/2;
- xfa->angle1 = 0;
- xfa->angle2 = 360*64;
- xfa++;
- xda->x = x - diam/2;
- xda->y = y - diam/2;
- xda->width = diam;
- xda->height = diam;
- xda->angle1 = 0;
- xda->angle2 = 360*64;
- xda++;
- break;
- case 'F': case 'K': /* diffuse and dark nebulea */
- /* open diamond */
- xs->x1 = x-diam/2; xs->y1 = y;
- xs->x2 = x; xs->y2 = y-diam/2; xs++;
- xs->x1 = x; xs->y1 = y-diam/2;
- xs->x2 = x+diam/2; xs->y2 = y; xs++;
- xs->x1 = x+diam/2; xs->y1 = y;
- xs->x2 = x; xs->y2 = y+diam/2; xs++;
- xs->x1 = x; xs->y1 = y+diam/2;
- xs->x2 = x-diam/2; xs->y2 = y; xs++;
- break;
- case 'N': /* bright nebulea */
- /* filled diamond */
- { XPoint p[5];
- p[0].x = x-diam/2; p[0].y = y;
- p[1].x = x; p[1].y = y-diam/2;
- p[2].x = x+diam/2; p[2].y = y;
- p[3].x = x; p[3].y = y+diam/2;
- p[4].x = x-diam/2; p[4].y = y;
- XFillPolygon (dsp, win, gc, p, 5, Convex, CoordModeOrigin);
- }
- break;
- case 'Q': /* Quasar */
- /* plus sign */
- xs->x1 = x-diam/2; xs->y1 = y;
- xs->x2 = x+diam/2; xs->y2 = y; xs++;
- xs->x1 = x; xs->y1 = y-diam/2;
- xs->x2 = x; xs->y2 = y+diam/2; xs++;
- break;
- case 'T': /* stellar object */
- case '\0': /* undefined type */
- default: /* unknown type */
- /* an X */
- xs->x1 = x-diam/3; xs->y1 = y-diam/3;
- xs->x2 = x+diam/3; xs->y2 = y+diam/3; xs++;
- xs->x1 = x-diam/3; xs->y1 = y+diam/3;
- xs->x2 = x+diam/3; xs->y2 = y-diam/3; xs++;
- break;
- }
- break;
- case HYPERBOLIC:
- case PARABOLIC:
- /* usually cometose -- draw a filled circle with tail */
- t = 3*diam/4;
- xfa->x = x - diam/4;
- xfa->y = y - diam/4;
- xfa->width = diam/2;
- xfa->height = diam/2;
- xfa->angle1 = 0;
- xfa->angle2 = 360*64;
- xfa++;
- xfa->x = x - t;
- xfa->y = y - t;
- xfa->width = 2*t;
- xfa->height = 2*t;
- xfa->angle1 = 120*64;
- xfa->angle2 = 30*64;
- xfa++;
- break;
- case ELLIPTICAL:
- /* filled square */
- XFillRectangle (dsp, win, gc, x-diam/2, y-diam/2, diam, diam);
- break;
- }
- }
-
- /* create the main skyview form */
- static void
- sv_create_svform()
- {
- static struct {
- char *name;
- void (*cb)();
- } cbs[] = {
- {"Filter", sv_filter_cb},
- {"Close", sv_close_cb},
- {"Help", sv_help_cb},
- };
- Widget rc_w;
- Widget w;
- Widget rb_w;
- Widget sep_w;
- Widget ctlfr_w, ctl_w;
- XmString str;
- Arg args[20];
- EventMask mask;
- int i, n;
-
- /* create form */
- n = 0;
- XtSetArg (args[n], XmNautoUnmanage, False); n++;
- XtSetArg (args[n], XmNdefaultPosition, False); n++;
- XtSetArg (args[n], XmNresizePolicy, XmRESIZE_NONE); n++;
- svform_w = XmCreateFormDialog (toplevel_w, "SkyView", args, n);
-
- /* set some stuff in the parent DialogShell.
- * setting XmNdialogTitle in the Form didn't work..
- */
- n = 0;
- XtSetArg (args[n], XmNtitle, "xephem Sky view"); n++;
- XtSetValues (XtParent(svform_w), args, n);
-
- /* make a form across the bottom in a frame for the control buttons */
-
- n = 0;
- XtSetArg (args[n], XmNbottomAttachment, XmATTACH_FORM); n++;
- XtSetArg (args[n], XmNleftAttachment, XmATTACH_FORM); n++;
- XtSetArg (args[n], XmNrightAttachment, XmATTACH_FORM); n++;
- ctlfr_w = XmCreateFrame (svform_w, "CtlFr", args, n);
- XtManageChild (ctlfr_w);
-
- n = 0;
- XtSetArg (args[n], XmNfractionBase, 10); n++;
- ctl_w = XmCreateForm (ctlfr_w, "CtlF", args, n);
- XtManageChild (ctl_w);
-
- /* make the control buttons */
-
- for (i = 0; i < XtNumber(cbs); i++) {
- n = 0;
- XtSetArg (args[n], XmNtopAttachment, XmATTACH_FORM); n++;
- XtSetArg (args[n], XmNtopOffset, 10); n++;
- XtSetArg (args[n], XmNbottomAttachment, XmATTACH_FORM); n++;
- XtSetArg (args[n], XmNbottomOffset, 10); n++;
- XtSetArg (args[n], XmNleftAttachment, XmATTACH_POSITION); n++;
- XtSetArg (args[n], XmNleftPosition, 1+i*3); n++;
- XtSetArg (args[n], XmNrightAttachment, XmATTACH_POSITION); n++;
- XtSetArg (args[n], XmNrightPosition, 3+i*3); n++;
- w = XmCreatePushButton (ctl_w, cbs[i].name, args, n);
- XtAddCallback (w, XmNactivateCallback, cbs[i].cb, 0);
- XtManageChild (w);
- }
-
- /* make a RowColumn down the left side for the misc controls */
-
- n = 0;
- XtSetArg (args[n], XmNtopAttachment, XmATTACH_FORM); n++;
- XtSetArg (args[n], XmNbottomAttachment, XmATTACH_WIDGET); n++;
- XtSetArg (args[n], XmNbottomWidget, ctlfr_w); n++;
- XtSetArg (args[n], XmNleftAttachment, XmATTACH_FORM); n++;
- XtSetArg (args[n], XmNisAligned, False); n++;
- XtSetArg (args[n], XmNadjustMargin, False); n++;
- rc_w = XmCreateRowColumn (svform_w, "SVRC", args, n);
- XtManageChild (rc_w);
-
- /* make the radio box for alt/az vs ra/dec */
-
- n = 0;
- rb_w = XmCreateRadioBox (rc_w, "SVModeRB", args, n);
- XtManageChild (rb_w);
-
- str = XmStringCreate ("Alt-Az", XmSTRING_DEFAULT_CHARSET);
- n = 0;
- XtSetArg (args[n], XmNlabelString, str); n++;
- XtSetArg (args[n], XmNalignment, XmALIGNMENT_BEGINNING); n++;
- aa_w = XmCreateToggleButton (rb_w, "AltAzMode", args, n);
- XtAddCallback (aa_w, XmNvalueChangedCallback, sv_aa_cb, NULL);
- XtManageChild (aa_w);
- XmStringFree (str);
-
- str = XmStringCreate ("RA-Dec", XmSTRING_DEFAULT_CHARSET);
- n = 0;
- XtSetArg (args[n], XmNlabelString, str); n++;
- XtSetArg (args[n], XmNalignment, XmALIGNMENT_BEGINNING); n++;
- rad_w = XmCreateToggleButton(rb_w, "RADecMode", args, n);
- XtManageChild (rad_w);
- XmStringFree (str);
-
- if(XmToggleButtonGetState(aa_w)==XmToggleButtonGetState(rad_w)){
- xe_msg("Sky View display mode conflicts -- using Alt/Az",0);
- aa_mode = 1; /* default to aa if they conflict */
- XmToggleButtonSetState (aa_w, aa_mode, False);
- XmToggleButtonSetState (rad_w, !aa_mode, False);
- }
- aa_mode = XmToggleButtonGetState(aa_w);
-
- n = 0;
- w = XmCreateSeparator (rc_w, "RCSep1", args, n);
- XtManageChild (w);
-
- /* make the "grid" toggle button and calibration labels */
-
- n = 0;
- XtSetArg (args[n], XmNalignment, XmALIGNMENT_BEGINNING); n++;
- w = XmCreateToggleButton (rc_w, "Grid", args, n);
- XtAddCallback (w, XmNvalueChangedCallback, sv_grid_cb, 0);
- XtManageChild (w);
-
- n = 0;
- XtSetArg (args[n], XmNalignment, XmALIGNMENT_BEGINNING); n++;
- vgrid_w = XmCreateLabel (rc_w, "SVGridV", args, n);
- set_xmstring (vgrid_w, XmNlabelString, null_grid_str);
- XtManageChild (vgrid_w);
-
- n = 0;
- XtSetArg (args[n], XmNalignment, XmALIGNMENT_BEGINNING); n++;
- hgrid_w = XmCreateLabel (rc_w, "SVGridH", args, n);
- set_xmstring (hgrid_w, XmNlabelString, null_grid_str);
- XtManageChild (hgrid_w);
-
- n = 0;
- w = XmCreateSeparator (rc_w, "RCSep2", args, n);
- XtManageChild (w);
-
- /* make the faint magnitude slider scale */
-
- str = XmStringCreate ("Faintest Mag", XmSTRING_DEFAULT_CHARSET);
- n = 0;
- XtSetArg (args[n], XmNorientation, XmHORIZONTAL); n++;
- XtSetArg (args[n], XmNminimum, BMAGLIMIT); n++;
- XtSetArg (args[n], XmNmaximum, FMAGLIMIT); n++;
- XtSetArg (args[n], XmNprocessingDirection, XmMAX_ON_LEFT); n++;
- XtSetArg (args[n], XmNscaleMultiple, 1); n++;
- XtSetArg (args[n], XmNshowValue, True); n++;
- XtSetArg (args[n], XmNtitleString, str); n++;
- fmag_w = XmCreateScale (rc_w, "FaintMagScale", args, n);
- XtAddCallback(fmag_w, XmNvalueChangedCallback, sv_changed_cb, NULL);
- XtAddCallback(fmag_w, XmNdragCallback, sv_magdrag_cb, NULL);
- XtManageChild (fmag_w);
- XmStringFree (str);
-
- /* make the bright magnitude slider scale */
-
- str = XmStringCreate ("Brightest Mag", XmSTRING_DEFAULT_CHARSET);
- n = 0;
- XtSetArg (args[n], XmNorientation, XmHORIZONTAL); n++;
- XtSetArg (args[n], XmNminimum, BMAGLIMIT); n++;
- XtSetArg (args[n], XmNmaximum, FMAGLIMIT); n++;
- XtSetArg (args[n], XmNprocessingDirection, XmMAX_ON_LEFT); n++;
- XtSetArg (args[n], XmNscaleMultiple, 1); n++;
- XtSetArg (args[n], XmNshowValue, True); n++;
- XtSetArg (args[n], XmNtitleString, str); n++;
- bmag_w = XmCreateScale (rc_w, "BrightMagScale", args, n);
- XtAddCallback(bmag_w, XmNvalueChangedCallback, sv_changed_cb, NULL);
- XtAddCallback(bmag_w, XmNdragCallback, sv_magdrag_cb, NULL);
- XtManageChild (bmag_w);
- XmStringFree (str);
-
- n = 0;
- w = XmCreateSeparator (rc_w, "RCSep3", args, n);
- XtManageChild (w);
-
- /* make the "just dots" toggle button */
-
- str = XmStringCreate ("Just Dots", XmSTRING_DEFAULT_CHARSET);
- n = 0;
- XtSetArg (args[n], XmNalignment, XmALIGNMENT_BEGINNING); n++;
- XtSetArg (args[n], XmNlabelString, str); n++;
- w = XmCreateToggleButton (rc_w, "JustDots", args, n);
- XtAddCallback (w, XmNvalueChangedCallback, sv_justdots_cb, NULL);
- XtManageChild (w);
- justdots = XmToggleButtonGetState (w);
- XmStringFree(str);
-
- /* make the "ecliptic" toggle button */
-
- str = XmStringCreate ("Ecliptic", XmSTRING_DEFAULT_CHARSET);
- n = 0;
- XtSetArg (args[n], XmNalignment, XmALIGNMENT_BEGINNING); n++;
- XtSetArg (args[n], XmNlabelString, str); n++;
- w = XmCreateToggleButton (rc_w, "Ecliptic", args, n);
- XtAddCallback (w, XmNvalueChangedCallback, sv_ecliptic_cb, NULL);
- XtManageChild (w);
- want_ecliptic = XmToggleButtonGetState (w);
- XmStringFree(str);
-
- /* make the "All labels" toggle button */
-
- str = XmStringCreate ("All labels", XmSTRING_DEFAULT_CHARSET);
- n = 0;
- XtSetArg (args[n], XmNalignment, XmALIGNMENT_BEGINNING); n++;
- XtSetArg (args[n], XmNlabelString, str); n++;
- w = XmCreateToggleButton (rc_w, "AllLabels", args, n);
- XtAddCallback (w, XmNvalueChangedCallback, sv_all_labels_cb, NULL);
- XtManageChild (w);
- all_labels = XmToggleButtonGetState (w);
- XmStringFree(str);
-
- n = 0;
- w = XmCreateSeparator (rc_w, "RCSep4", args, n);
- XtManageChild (w);
-
- /* make the "find" cascade button */
- sv_create_find (rc_w);
-
- /* make a vertical sep to the right of the left row/col */
-
- n = 0;
- XtSetArg (args[n], XmNtopAttachment, XmATTACH_FORM); n++;
- XtSetArg (args[n], XmNbottomAttachment, XmATTACH_WIDGET); n++;
- XtSetArg (args[n], XmNbottomWidget, ctlfr_w); n++;
- XtSetArg (args[n], XmNleftAttachment, XmATTACH_WIDGET); n++;
- XtSetArg (args[n], XmNleftWidget, rc_w); n++;
- XtSetArg (args[n], XmNorientation, XmVERTICAL); n++;
- sep_w = XmCreateSeparator (svform_w, "Sep1", args, n);
- XtManageChild(sep_w);
-
- /* make a timestamp label just above the control panel's frame */
-
- n = 0;
- XtSetArg (args[n], XmNleftAttachment, XmATTACH_WIDGET); n++;
- XtSetArg (args[n], XmNleftWidget, sep_w); n++;
- XtSetArg (args[n], XmNrightAttachment, XmATTACH_FORM); n++;
- XtSetArg (args[n], XmNbottomAttachment, XmATTACH_WIDGET); n++;
- XtSetArg (args[n], XmNbottomWidget, ctlfr_w); n++;
- XtSetArg (args[n], XmNalignment, XmALIGNMENT_CENTER); n++;
- dt_w = XmCreateLabel (svform_w, "TimeStamp", args, n);
- XtManageChild(dt_w);
-
- /* make the bottom scale above the time stamp */
-
- n = 0;
- XtSetArg (args[n], XmNleftAttachment, XmATTACH_WIDGET); n++;
- XtSetArg (args[n], XmNleftWidget, sep_w); n++;
- XtSetArg (args[n], XmNrightAttachment, XmATTACH_FORM); n++;
- XtSetArg (args[n], XmNbottomAttachment, XmATTACH_WIDGET); n++;
- XtSetArg (args[n], XmNbottomWidget, dt_w); n++;
-