v11i038: starchart 3.2 Part 10/32
ccount at ATHENA.MIT.EDU
ccount at ATHENA.MIT.EDU
Fri Mar 16 10:34:16 AEST 1990
Posting-number: Volume 11, Issue 38
Submitted-by: ccount at ATHENA.MIT.EDU
Archive-name: starchart/part10
#! /bin/sh
# This is a shell archive. Remove anything before this line, then unpack
# it by saving it into a file and typing "sh file". To overwrite existing
# files, type "sh file -c". You can also feed this as standard input via
# unshar, or by typing "sh <file", e.g.. If this archive is complete, you
# will see the following message at the end:
# "End of archive 10 (of 32)."
# Contents: starchart/starX10.c starchart/stardsp.c
# starchart/starsample.c
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f 'starchart/starX10.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'starchart/starX10.c'\"
else
echo shar: Extracting \"'starchart/starX10.c'\" \(14957 characters\)
sed "s/^X//" >'starchart/starX10.c' <<'END_OF_FILE'
X/*
X * X10 Driver for starchart 3.0. Craig Counterman Jan, 1989
X *
X *
X * Copyright (c) 1990 by Craig Counterman. All rights reserved.
X *
X * This software may be redistributed freely, not sold.
X * This copyright notice and disclaimer of warranty must remain
X * unchanged.
X *
X * No representation is made about the suitability of this
X * software for any purpose. It is provided "as is" without express or
X * implied warranty, to the extent permitted by applicable law.
X *
X */
X
Xstatic char rcsid[]="$Header: starX10.c,v 2.3 90/02/19 17:52:58 ccount Exp $";
X
X#include <stdio.h>
X#include <math.h>
X#include <ctype.h>
X#include "star3.h"
X
X#ifndef SYSV
X#include <strings.h>
X#else
X#include <string.h>
X#endif
X
X#include <X/Xlib.h>
X/*#include "Xlib.h"*/
X
X/* Cursor for window */
X#define target_width 16
X#define target_height 16
X#define target_x_hot 8
X#define target_y_hot 8
Xshort target_bits[] = {
X 0x0000, 0x0280, 0x0280, 0x0ee0,
X 0x1290, 0x2288, 0x26c8, 0xfd7e,
X 0x0280, 0xfd7e, 0x26c8, 0x2288,
X 0x1290, 0x0ee0, 0x0280, 0x0280};
X#define target_mask_width 16
X#define target_mask_height 16
X#define target_mask_x_hot 8
X#define target_mask_y_hot 8
Xshort target_mask_bits[] = {
X 0x0000, 0x0280, 0x0380, 0x0fe0,
X 0x1390, 0x2388, 0x26c8, 0xfd7e,
X 0x7abc, 0xfd7e, 0x26c8, 0x2388,
X 0x1390, 0x0fe0, 0x0380, 0x0280};
X
X/* Use array of styles and fonts */
X#define MAXLNSTY MAXSTLNS
X#define MAXFONTS 100
X
X/* X items */
XDisplay *display; /* connection to display server */
XWindow window; /* window to graphics in */
Xint planes; /* plane mask */
Xint *pixels; /* color map cells */
XCursor cursor; /* current cursor */
Xint inmask; /* input mask for window */
Xint ncolors; /* number of colors */
Xint is_color; /* is color workstation */
Xint colr; /* current color */
Xint forepix, backpix;
XFontInfo *D_Fonts[MAXFONTS];
XFontInfo *D_GrkFont;
XFontInfo *current_font;
Xint D_Linesty[MAXLNSTY];
X
X#define BLACK 0
X#define WHITE 1
X#define RED 2
X#define ORANGE 3
X#define YELLOW 4
X#define GREEN 5
X#define CYAN 6
X#define BLUE 7
X#define VIOLET 8
X#define BLUE_WHITE 9
X
X
X/* Externs */
Xextern int g_argc;
Xextern char **g_argv;
X
Xextern char *title; /* Title of page */
X
Xextern mapwindow *mapwin[MAXWINDOWS];
Xextern int numwins;
X
Xextern int cur_function;
Xextern int cur_map_type;
Xextern int cur_map_tag;
Xextern char *cur_tag_field;
X
X
X/* Scale multiplier, minimum,
X mangitude change, maximum, for thumbnail,*/
X#define THSMUL 1.2
X#define THSMIN 12.0
X#define THMADJ 2.5
X#define THMMAX 5.0
X
X/* size of window */
X#define WINWID 1020
X#define WINHGT 800
X
X
X/* Exports */
X
X/* The variables in the first few lines MUST be set by driver */
Xmapwindow fullpage = {
X 880, 700, 20, 65, /* width, height, x and y offsets */
X 8.0, 2.0, 2.05, /* default limiting mags for glyph, name, label */
X
X/* The next several variables SHOULD be set by the driver,
X but are only used by the driver */
X FULLPAGEMAP, /* Type of map: THUMBNAIL may have
X some restrictions */
X 0, /* May be used by driver for whatever */
X "String", /* May be used by driver for whatever */
X
X/* The next several variables may be set by the driver, but the main routines
X may reset them (and the driver routines may then override that) */
X SANSONS, /* Projection mode */
X FALSE, FALSE, /* Draw grids */
X 0.5, 5.0, /* grid step size */
X 0.0, 0.0, /* grid origin */
X
X FALSE, /* Invert (flip north south) */
X};
X
X/* The variables in the first few lines MUST be set by driver */
Xmapwindow mainmap = {
X 880, 500, 20, 265, /* width, height, x and y offsets */
X 8.0, 2.0, 2.05, /* default limiting mags for glyph, name, label */
X
X/* The next several variables SHOULD be set by the driver,
X but are only used by the driver */
X MAINMAP, /* Type of map: THUMBNAIL may have
X some restrictions */
X 0, /* May be used by driver for whatever */
X "String", /* May be used by driver for whatever */
X
X/* The next several variables may be set by the driver, but the main routines
X may reset them (and the driver routines may then override that) */
X SANSONS, /* Projection mode */
X FALSE, FALSE, /* Draw grids */
X 0.5, 5.0, /* grid step size */
X 0.0, 0.0, /* grid origin */
X
X FALSE, /* Invert (flip north south) */
X};
X
X
X/* The variables in the first few lines MUST be set by driver */
Xmapwindow thumbmap = {
X 480, 195, 420, 35, /* width, height, x and y offsets */
X 5.5+THMADJ, 1.0+THMADJ, 2.05+THMADJ,
X /* default limiting mags for glyph, name, label */
X
X/* The next several variables SHOULD be set by the driver,
X but are only used by the driver */
X THUMBNAIL, /* Type of map: THUMBNAIL may have
X some restrictions */
X 0, /* May be used by driver for whatever */
X "String", /* May be used by driver for whatever */
X
X/* The next several variables may be set by the driver, but the main routines
X may reset them (and the driver routines may then override that) */
X SANSONS, /* Projection mode */
X FALSE, FALSE, /* Draw grids */
X 0.5, 5.0, /* grid step size */
X 0.0, 0.0, /* grid origin */
X
X FALSE, /* Invert (flip north south) */
X};
X
X/* h & v tick text controls */
Xint htick_lim = 2;
Xint htext_lim = 80;
Xint htext_xoff = 2;
Xint htext_yoff = 17;
Xint vtick_lim = 2;
Xint vtext_lim = 20;
Xint vtext_xoff = 24;
Xint vtext_yoff = 0;
X
X/* externs for labels */
Xint x_nameoffset = 10, y_nameoffset = 0;
Xint x_lbloffset = 7, y_lbloffset = 10;
Xint x_magoffset = 7, y_magoffset = -10;
X
X/* externs for legend: variables of positioning are here */
Xint l_til=220;
Xint l_stil=185;
X
Xint l_lmar1=40;
Xint l_lmar2=65;
Xint l_ltext=95;
Xint l_rmar1=205;
Xint l_rmar2=230;
Xint l_rtext=260;
X
Xint l_line1=150;
Xint l_line2=125;
Xint l_line3=100;
Xint l_line4=75;
Xint l_line5=50;
Xint l_line6=25;
X
X/* Point sizes for font calls */
Xint titlesize=16;
Xint subtlsize=12;
Xint namesize=10;
Xint lblsize=8;
Xint magsize=8;
X
X/* Fonts for font calls */
Xint namefnt=TIMESROMAN;
Xint lblfnt=HELV;
Xint magfnt=COURIER;
Xint titlefnt=TIMESBOLD;
Xint subtlfnt=TIMESROMAN;
X
X/* Scale multiplier, minimum,
X mangitude change, maximum, for thumbnail,*/
Xdouble th_smul = THSMUL;
Xdouble th_smin = THSMIN;
Xdouble th_madj = THMADJ;
Xdouble th_mmax = THMMAX;
X
X#define MAX(a,b) ((a)>(b)?(a):(b))
X#define MIN(a,b) ((a)<(b)?(a):(b))
X
X/* Device control argument */
XD_control_arg(s)
Xchar *s;
X{
X int i = 0;
X int c;
X
X while (c = s[i++]) switch (c) {
X default:
X break;
X }
X}
X
X/* Open the device */
XD_open()
X{
X char *wname;
X extern char *getenv();
X char *str, *prog = "Starchart"; /* default name string */
X char *fore_color, *back_color;
X int reverse = 1;
X Color cdef;
X
X wname= NULL;
X
X if ( !(display = XOpenDisplay(wname)))
X return FALSE;
X
X if ((str = XGetDefault(prog, "ReverseVideo")) && strcmp(str, "on") == 0)
X reverse = 0;
X fore_color = XGetDefault(prog, "ForeGround");
X back_color = XGetDefault(prog, "BackGround");
X
X cursor=XCreateCursor(target_width,target_height,
X target_bits,target_mask_bits,
X target_x_hot,target_y_hot,
X BlackPixel,WhitePixel,GXcopy);
X
X
X /* create color map */
X
X if (reverse) {
X forepix = BlackPixel;
X backpix = WhitePixel;
X }
X else {
X forepix = WhitePixel;
X backpix = BlackPixel;
X }
X
X is_color = (DisplayPlanes() >= 4);
X ncolors = (is_color ? 12 : 2);
X
X pixels = (int *) malloc((long) ncolors*sizeof(int));
X if (is_color) {
X if (!XGetColorCells(0, ncolors, 0, &planes, pixels)) {
X fprintf(stderr, "Error, can't get color cells\n");
X exit(10);
X }
X
X if (!fore_color || !XParseColor(fore_color, &cdef)) {
X cdef.pixel = forepix ;
X XQueryColor(&cdef) ;
X }
X cdef.pixel = pixels[0] ;
X XStoreColor(&cdef) ;
X if (!back_color || !XParseColor(back_color, &cdef)) {
X cdef.pixel = backpix ;
X XQueryColor(&cdef) ;
X }
X cdef.pixel = pixels[1] ;
X XStoreColor(&cdef) ;
X D_setcolors();
X } else {
X pixels[BLACK] = backpix ;
X pixels[WHITE] = forepix ;
X }
X
X colr = pixels[WHITE];
X
X /* open window */
X window = XCreateWindow(RootWindow,0,0,WINWID,WINHGT,2,WhitePixmap,
X BlackPixmap);
X XMapWindow(window) ;
X XDefineCursor(window,cursor);
X inmask = ButtonPressed|KeyPressed|ExposeWindow ;
X XSelectInput(window, inmask) ;
X
X D_setfnts();
X D_setlinesty();
X
X XFlush();
X
X return TRUE ; /* open successful */
X}
X
X/* Close the device */
XD_close()
X{
X Window closebox;
X XEvent rep; /*isn't really used*/
X
X XFlush();
X /* create a close box */
X closebox=XCreateWindow(window,0,0,20,20,0,WhitePixmap,BlackPixmap);
X
X XMapWindow(closebox);
X XSelectInput(closebox,ButtonPressed);
X XWindowEvent(closebox,ButtonPressed,&rep);
X XUndefineCursor(window);
X XFreeCursor(cursor);
X XDestroyWindow(window) ;
X XCloseDisplay(display) ;
X}
X
X
Xstatic int current_x, current_y;
X
X/* Move to (x, y) */
XD_move(x, y)
X int x, y;
X{
X current_x = x;
X current_y = y;
X}
X
X
X/* Draw a line of style line_style from the current point to (x, y) */
X/* Note, this replaces vecdraw vecdrawdot and vecdrawhyph */
XD_draw(x, y, line_style)
X int x, y;
X int line_style; /* SOLID, DOTTED, DASHED, etc. */
X{
X Vertex line[2];
X int l_style;
X
X line[0].x = current_x;
X line[0].y = WINHGT - current_y;
X line[1].x = x;
X line[1].y = WINHGT - y;
X line[0].flags = line[1].flags = 0;
X
X switch (cur_function) {
X case CHRTOUTLN:
X case CHRTHTICK:
X case CHRTVTICK:
X l_style = SOLID;
X break;
X case GRID_RA:
X case GRID_DEC:
X l_style = DASHED;
X break;
X case ECLIPT:
X l_style = DOTTED;
X break;
X case CONSTBOUND:
X l_style = DASHED;
X break;
X case CONSTPATTRN:
X l_style = DOTTED;
X break;
X case CONSTNAME:
X case CHARTFILE:
X l_style = line_style;
X break;
X default:
X l_style = line_style;
X break;
X }
X
X XDrawDashed(window, line, 2, 1, 1, (is_color ? colr : pixels[BLACK]),
X D_Linesty[l_style], GXcopy, AllPlanes);
X
X current_x = x;
X current_y = y;
X}
X/* This routine is encouraged to look at the extern cur_funtion
X and change the line style drawn as desired */
X
X/* Move to (x1, y1) then draw a line of style line_style to (x2, y2) */
XD_movedraw(x1, y1, x2, y2, line_style)
X int x1, y1, x2, y2;
X int line_style; /* SOLID, DOTTED, DASHED, etc. */
X{
X D_move(x1, y1);
X D_draw(x2, y2, line_style);
X}
X
X/* Set the color to be used for lines and text */
X/* color_str is a 2 char (+ '\0') string
X containing a specification for a color,
X e.g. "G2" for the color of a star of spectral class G2, or "r7" for
X red, level seven. The interpretation of the color string is left to
X the device driver */
XD_color(color_str)
X char *color_str;
X{
X if (!is_color) return;
X
X switch (color_str[0]) {
X case 'O':
X colr = pixels[BLUE_WHITE];
X break;
X case 'B':
X colr = pixels[BLUE];
X break;
X case 'A':
X colr = pixels[WHITE];
X break;
X case 'F':
X colr = pixels[WHITE];
X break;
X case 'G':
X colr = pixels[YELLOW];
X break;
X case 'K':
X colr = pixels[ORANGE];
X break;
X case 'M':
X colr = pixels[RED];
X break;
X case 'R':
X case 'N':
X case 'S':
X colr = pixels[RED];
X break;
X case ' ':
X default:
X colr = pixels[WHITE];
X break;
X }
X}
X
X
X/* Set the font and font size to be used for text. */
X/* Note order of args */
XD_fontsize(fsize, font)
X int fsize; /* Size of font */
X int font; /* e.g. TIMES, HELV, TIMES+ITALIC */
X{
X switch(cur_function) {
X case CHRTOUTLN:
X case CHRTHTICK:
X case CHRTVTICK:
X current_font = D_Fonts[TIMESBOLD];
X case GRID_RA:
X case GRID_DEC:
X case ECLIPT:
X case CONSTBOUND:
X case CONSTPATTRN:
X break;
X case CONSTNAME:
X current_font = D_Fonts[TIMESROMAN];
X case CHARTFILE:
X case CURNTFONT:
X default:
X break;
X }
X}
X/* This routine is encouraged to look at the extern cur_funtion
X and change the font used as desired */
X
X
X/* Display text string str at x,y, in current font and font size.
X if star_lbl is TRUE, string is a star label, use
X greek characters (if possible) */
XD_text(x, y, str, star_lbl)
X int x, y;
X char *str;
X int star_lbl;
X{
X FontInfo *tfont;
X
X if (star_lbl) {
X if (isgreek(str[0]) && (isdigit(str[1]) || (str[1] == ' '))) {
X tfont = D_GrkFont;
X } else { /* Star label, but not greek */
X /* remove leading spaces */
X while (*str == ' ') str++;
X tfont = current_font;
X }
X } else tfont = current_font;
X
X XText(window, x, WINHGT - y, str, strlen(str),
X tfont->id,
X backpix, forepix);
X}
X
Xisgreek(c)
Xchar c;
X{
X char *cp;
X
X#ifdef OLD_GREEK
X cp = "abgdezh at iklmnEoprstuOx%w";
X#else
X cp = "abgdezhqiklmnxoprstujcyw";
X#endif
X while (*cp && (*cp != c)) cp++;
X return (*cp != '\0'); /* True if letter was in greek string */
X}
X
X
X
X/* Return input coordinate in device coords where there are pointing devices */
XD_inxy(x, y)
X int *x, *y;
X{
X}
X
X/* Put non-displayed comment in output. Allowed in postscript, but
X few other drivers will be able to support this. */
XD_comment(str)
X char *str;
X{
X fprintf(stderr, "%s\n", str);
X}
X
X
X/**
XHigher level functions
X**/
X
Xdrawlen(x, y, dx, dy, len)
X int x, y, dx, dy, len;
X{
X D_movedraw(x + dx, y + dy, x + dx + len, y + dy, SOLID);
X}
X
XD_setfnts()
X{
X D_Fonts[TIMESROMAN] = XOpenFont("6x10");
X D_Fonts[TIMESBOLD] = XOpenFont("6x10");
X D_Fonts[TIMESITAL] = XOpenFont("6x10");
X D_Fonts[TIMESBOLDITAL] = XOpenFont("6x10");
X D_Fonts[HELV] = XOpenFont("6x10");
X D_Fonts[HELVBOLD] = XOpenFont("6x10");
X D_Fonts[HELVITAL] = XOpenFont("6x10");
X D_Fonts[HELVBOLDITAL] = XOpenFont("6x10");
X D_Fonts[COURIER] = XOpenFont("6x10");
X D_Fonts[COURBOLD] = XOpenFont("6x10");
X D_Fonts[COURITAL] = XOpenFont("6x10");
X D_Fonts[COURITALBOLD] = XOpenFont("6x10");
X D_GrkFont = XOpenFont("6x10");
X
X current_font = D_Fonts[TIMESROMAN];
X}
X
XD_setlinesty()
X{
X D_Linesty[SOLID] = SolidLine;
X D_Linesty[DOTTED] = (is_color ? DottedLine : SolidLine);
X D_Linesty[DASHED] = (is_color ? DashedLine : SolidLine);
X D_Linesty[VECSOLID] = SolidLine;
X D_Linesty[VECDOT] = (is_color ? DottedLine : SolidLine);
X D_Linesty[VECDASH] = (is_color ? DashedLine : SolidLine);
X}
X
XD_setcolors()
X{
X Color c ;
X
X c.red = 256*0;
X c.green = 256*0;
X c.blue = 256*0;
X c.pixel = pixels[BLACK];
X XStoreColor(&c);
X
X c.red = 256*255;
X c.green = 256*255;
X c.blue = 256*255;
X c.pixel = pixels[WHITE];
X XStoreColor(&c);
X
X c.red = 256*255;
X c.green = 256*0;
X c.blue = 256*0;
X c.pixel = pixels[RED];
X XStoreColor(&c);
X
X c.red = 256*255;
X c.green = 256*100;
X c.blue = 256*0;
X c.pixel = pixels[ORANGE];
X XStoreColor(&c);
X
X c.red = 256*255;
X c.green = 256*255;
X c.blue = 256*0;
X c.pixel = pixels[YELLOW];
X XStoreColor(&c);
X
X c.red = 256*0;
X c.green = 256*0;
X c.blue = 256*255;
X c.pixel = pixels[GREEN];
X XStoreColor(&c);
X
X c.red = 256*0;
X c.green = 256*255;
X c.blue = 256*255;
X c.pixel = pixels[CYAN];
X XStoreColor(&c);
X
X c.red = 256*0;
X c.green = 256*0;
X c.blue = 256*255;
X c.pixel = pixels[BLUE];
X XStoreColor(&c);
X
X c.red = 256*255;
X c.green = 256*0;
X c.blue = 256*255;
X c.pixel = pixels[VIOLET];
X XStoreColor(&c);
X
X c.red = 256*130;
X c.green = 256*130;
X c.blue = 256*255;
X c.pixel = pixels[BLUE_WHITE];
X XStoreColor(&c);
X XFlush();
X}
X
X
END_OF_FILE
if test 14957 -ne `wc -c <'starchart/starX10.c'`; then
echo shar: \"'starchart/starX10.c'\" unpacked with wrong size!
fi
# end of 'starchart/starX10.c'
fi
if test -f 'starchart/stardsp.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'starchart/stardsp.c'\"
else
echo shar: Extracting \"'starchart/stardsp.c'\" \(17440 characters\)
sed "s/^X//" >'starchart/stardsp.c' <<'END_OF_FILE'
X/*
X * TTY Display driver for starchart.c mainline
X */
X
X/*
X ! patched December, 1987 by Alan Paeth (awpaeth at watcgl),
X !
X ! [1] formal/actual parmaters for drawNebu, drawPlan.. now agree
X ! [2] "bigmaster" chart layout now added
X !
X * Modified for starchart 3.0. Craig Counterman Jan, 1989
X *
X * Copyright (c) 1990 by Craig Counterman. All rights reserved.
X *
X * This software may be redistributed freely, not sold.
X * This copyright notice and disclaimer of warranty must remain
X * unchanged.
X *
X * No representation is made about the suitability of this
X * software for any purpose. It is provided "as is" without express or
X * implied warranty, to the extent permitted by applicable law.
X *
X */
X
Xstatic char rcsid[]="$Header: stardsp.c,v 2.4 90/02/19 17:55:01 ccount Exp $";
X
X#include <stdio.h>
X#include <math.h>
X#ifndef SYSV
X#include <strings.h>
X#else
X#include <string.h>
X#endif
X#include <ctype.h>
X#include "star3.h"
X
X/* Externs */
Xextern int g_argc;
Xextern char **g_argv;
X
Xextern char *title; /* Title of page */
X
Xextern mapwindow *mapwin[MAXWINDOWS];
Xextern int numwins;
X
Xextern int cur_function;
Xextern int cur_map_type;
Xextern int cur_map_tag;
Xextern char *cur_tag_field;
X
X
X/* Scale multiplier, minimum,
X mangitude change, maximum, for thumbnail,*/
X#define THSMUL 1.2
X#define THSMIN 12.0
X#define THMADJ 2.5
X#define THMMAX 5.0
X
X
X/* Exports */
X
X/* The variables in the first few lines MUST be set by driver */
Xmapwindow fullpage = {
X 880, 700, 20, 65, /* width, height, x and y offsets */
X 5.9, 2.0, 2.05, /* default limiting mags for glyph, name, label */
X
X/* The next several variables SHOULD be set by the driver,
X but are only used by the driver */
X FULLPAGEMAP, /* Type of map: THUMBNAIL may have
X some restrictions */
X 0, /* May be used by driver for whatever */
X "String", /* May be used by driver for whatever */
X
X/* The next several variables may be set by the driver, but the main routines
X may reset them (and the driver routines may then override that) */
X SANSONS, /* Projection mode */
X FALSE, FALSE, /* Draw grids */
X 0.5, 5.0, /* grid step size */
X 0.0, 0.0, /* grid origin */
X
X FALSE, /* Invert (flip north south) */
X};
X
X/* The variables in the first few lines MUST be set by driver */
Xmapwindow mainmap = {
X 880, 500, 20, 265, /* width, height, x and y offsets */
X 5.9, 2.0, 2.05, /* default limiting mags for glyph, name, label */
X
X/* The next several variables SHOULD be set by the driver,
X but are only used by the driver */
X MAINMAP, /* Type of map: THUMBNAIL may have
X some restrictions */
X 0, /* May be used by driver for whatever */
X "String", /* May be used by driver for whatever */
X
X/* The next several variables may be set by the driver, but the main routines
X may reset them (and the driver routines may then override that) */
X SANSONS, /* Projection mode */
X FALSE, FALSE, /* Draw grids */
X 0.5, 5.0, /* grid step size */
X 0.0, 0.0, /* grid origin */
X
X FALSE, /* Invert (flip north south) */
X};
X
X
X/* The variables in the first few lines MUST be set by driver */
Xmapwindow thumbmap = {
X 480, 195, 420, 35, /* width, height, x and y offsets */
X 3.0+THMADJ, 1.0+THMADJ, 2.05+THMADJ,
X /* default limiting mags for glyph, name, label */
X
X/* The next several variables SHOULD be set by the driver,
X but are only used by the driver */
X THUMBNAIL, /* Type of map: THUMBNAIL may have
X some restrictions */
X 0, /* May be used by driver for whatever */
X "String", /* May be used by driver for whatever */
X
X/* The next several variables may be set by the driver, but the main routines
X may reset them (and the driver routines may then override that) */
X SANSONS, /* Projection mode */
X FALSE, FALSE, /* Draw grids */
X 0.5, 5.0, /* grid step size */
X 0.0, 0.0, /* grid origin */
X
X FALSE, /* Invert (flip north south) */
X};
X
X/* h & v tick text controls */
Xint htick_lim = 2;
Xint htext_lim = 80;
Xint htext_xoff = 2;
Xint htext_yoff = 17;
Xint vtick_lim = 2;
Xint vtext_lim = 20;
Xint vtext_xoff = 24;
Xint vtext_yoff = 0;
X
X/* Scale multiplier, minimum,
X mangitude change, maximum, for thumbnail,*/
Xdouble th_smul=THSMUL;
Xdouble th_smin=THSMIN;
Xdouble th_madj=THMADJ;
Xdouble th_mmax=THMMAX;
X
X#define MAX(a,b) ((a)>(b)?(a):(b))
X#define MIN(a,b) ((a)<(b)?(a):(b))
X
X#define ROWS 32L
X#define COLS 79L
X
X/* Device control argument */
XD_control_arg(s)
Xchar *s;
X{
X int i = 0;
X int c;
X
X while (c = s[i++]) switch (c) {
X default:
X break;
X }
X}
X
Xint oldx, oldy, scrx, scry; /* Must be 32 bits */
Xchar **linevec;
Xchar *calloc();
X
X
X/* Open the device */
XD_open()
X{
X int i;
X
X linevec = (char**)(calloc((unsigned)ROWS, sizeof(char*)));
X if (linevec == NULL) return FALSE;
X for (i=0; i<ROWS; i++) {
X linevec[i] = (char*)(calloc((unsigned)COLS, sizeof(char)));
X if (linevec[i] == NULL) return FALSE;
X }
X
X return TRUE ; /* open successful */
X}
X
X
X/* Close the device */
XD_close()
X{
X int i, j, k;
X char c;
X
X for (i=0; i<ROWS; i++)
X {
X for (j=COLS-1; j>0; j--) if (linevec[i][j]) break;
X for (k=0; k<=j; k++) putchar((c=linevec[i][k]) ? c : ' ');
X putchar('\n');
X free((char *)linevec[i]);
X }
X fflush(stdout);
X free((char *)linevec);
X}
X
X
X/* Move to (x, y) */
XD_move(x, y)
X int x, y;
X{
X oldx = x;
X oldy = y;
X scrx = (x*COLS+512L)/1024L;
X scry = (((768L-y)*ROWS)+384L)/768L;
X}
X
X
X/* Draw a line of style line_style from the current point to (x, y) */
X/* Note, this replaces vecdraw vecdrawdot and vecdrawhyph */
XD_draw(x, y, line_style)
X int x, y;
X int line_style; /* SOLID, DOTTED, DASHED, etc. */
X{
X int dx, dy, savex, savey, i, steps;
X char c;
X
X /* all styles are the same */
X savex = oldx;
X savey = oldy;
X dx = x-oldx;
X dy = y-oldy;
X c = (abs(dx) > abs(dy)) ? '-' : '|';
X steps = MAX(MAX(abs(dx),abs(dy))/12, 1);
X for(i=0; i<=steps; i++)
X {
X D_move(savex+(i*dx+steps/2)/steps,savey+(i*dy+steps/2)/steps);
X sym(c);
X }
X}
X/* This routine is encouraged to look at the extern cur_funtion
X and change the line style drawn as desired */
X
X
X/* Move to (x1, y1) then draw a line of style line_style to (x2, y2) */
XD_movedraw(x1, y1, x2, y2, line_style)
X int x1, y1, x2, y2;
X int line_style; /* SOLID, DOTTED, DASHED, etc. */
X{
X D_move(x1, y1);
X D_draw(x2, y2, line_style);
X}
X
X
X/* Set the color to be used for lines and text */
X/* color_str is a 2 char (+ '\0') string containing
X a specification for a color,
X e.g. "G2" for the color of a star of spectral class G2, or "r7" for
X red, level seven. The interpretation of the color string is left to
X the device driver */
XD_color(color_str)
X char *color_str;
X{
X switch (color_str[0]) {
X case 'O':
X break;
X case 'B':
X break;
X case 'A':
X break;
X case 'F':
X break;
X case 'G':
X break;
X case 'K':
X break;
X case 'M':
X break;
X case 'R':
X case 'N':
X case 'S':
X break;
X case 'r':
X case 'g':
X case 'b':
X case 'y':
X case 'c':
X case 'p':
X case 'o':
X case 'w':
X break;
X case ' ':
X default:
X break;
X }
X}
X
X
X/* Set the font and font size to be used for text. */
X/* Note order of args */
XD_fontsize(fsize, font)
X int fsize; /* Size of font */
X int font; /* e.g. TIMES, HELV, TIMES+ITALIC */
X{
X}
X/* This routine is encouraged to look at the extern cur_funtion
X and change the font used as desired */
X
X
X/* Display text string str at x,y, in current font and font size.
X if star_lbl is TRUE, string is a star label, use
X greek characters (if possible) */
XD_text(x, y, str, star_lbl)
X int x, y;
X char *str;
X int star_lbl;
X{
X char c;
X
X D_move(x, y);
X
X if (star_lbl) {
X /* remove leading spaces */
X while (*str == ' ') str++;
X /* can't display greek characters */
X }
X
X while(c = *str++)
X {
X sym(c);
X scrx++;
X }
X}
X
X
Xchar char_overwrite();
X
Xsym(c)
X char c;
X{
X if ( (scrx >= 0) && (scrx < COLS) &&
X (scry >= 0) && (scry < ROWS) )
X linevec[scry][scrx] = char_overwrite(linevec[scry][scrx], c );
X}
X
X
Xchar char_overwrite(under, over)
X char under, over;
X{
X if (over == under) return(over);
X if (!under) return(over);
X if (!over) return(under);
X if (isspace(under)) return(over);
X if (isspace(over)) return(under);
X if (over == '%') return(over);
X if (over == '~') return(over);
X if (over == '@') return(over);
X if (under == '%') return(under);
X if (under == '~') return(under);
X if (under == '@') return(under);
X if ( isalnum(under) && isalnum(over)) return(over);
X if (!isalnum(under) && isalnum(over)) return(over);
X if ( isalnum(under) && !isalnum(over)) return(under);
X if ((under == '-') && (over == '|')) return('+');
X if ((under == '|') && (over == '-')) return('+');
X if ((under == '+') && (over == '-')) return('+');
X if ((under == '+') && (over == '|')) return('+');
X if ((under == ',') && (over == '.')) return(';');
X if ((under == '.') && (over == ',')) return(';');
X if ((under == '.') && (over == '.')) return(':');
X if ((under == '|') && (over == '.')) return('!');
X if ((under == '|') && (over == ',')) return('!');
X if ((under == '.') && (over == '|')) return('!');
X if ((under == ',') && (over == '|')) return('!');
X if ((under == '.') && (over == '.')) return(':');
X return(under);
X}
X
X
X/* Return input coordinate in device coords where there are pointing devices */
XD_inxy(x, y)
X int *x, *y;
X{
X}
X
X
X/* Put non-displayed comment in output. Allowed in postscript, but
X few other drivers will be able to support this. */
XD_comment(str)
X char *str;
X{
X/*
X fprintf(stderr, "%s\n", str);
X*/
X}
X
X
X/**
XHigher level functions
X**/
X
X/* Point sizes for font calls */
X#define TITLESIZE 16
X#define SUBTLSIZE 12
X#define NAMESIZE 10
X#define LBLSIZE 8
X#define MAGSIZE 8
X
X/* Fonts for font calls */
X#define NAMEFNT TIMESROMAN
X#define LBLFNT HELV
X#define MAGFNT COURIER
X#define TITLEFNT TIMESBOLD
X#define SUBTLFNT TIMESROMAN
X
Xint x_nameoffset = 10, y_nameoffset = 0;
Xint x_lbloffset = 0, y_lbloffset = 10;
Xint x_magoffset = 7, y_magoffset = -15;
X
X
X/* Interface Function */
X/* Draw object at x, y. properties set by other parameters */
Xdrawobj(x, y, mag, type, color_str, label_field, con_str, obj_name,
X comment_str, file_line,
X draw_glyph, draw_text, use_lbl, use_name, use_mag)
X
X int x, y;
X double mag; /* Magnitude of object */
X char *type; /* 2 chars, object code and subcode */
X char *color_str; /* 2 chars, spectral type for stars,
X color code otherwise */
X char *label_field; /* 2 chars, Bayer or flamsteed for stars,
X size in seconds for nebulae and
X planets */
X char *con_str; /* 3 chars, the constellation the object is in */
X char *obj_name; /* Name of object */
X char *comment_str; /* Comment field */
X char *file_line; /* The full line from the file,
X containing the above if it is in
X standard format */
X int draw_glyph; /* Draw object symbol */
X int draw_text; /* Draw text */
X int use_lbl; /* Label object with the label_field string */
X int use_name; /* Label object with the obj_name string */
X int use_mag; /* Label object with a 2 or 3 character string
X containing the magnitude * 10 without
X decimal point */
X{
X char magstr[10];
X
X/*fprintf(stderr, "%d %d %f <%s> <%s> <%s> <%s> <%s> <%s> <%s>\n", x, y, mag,
X type, color_str, label_field, con_str, obj_name, comment_str,
X file_line);*/
X
X if (draw_glyph)
X switch(type[0]) {
X case 'S': drawStar(x,y,mag,type[1],color_str);
X break;
X case 'P': drawPlan(x,y,mag,type[1],color_str, size_obj(label_field),
X comment_str);
X break;
X case 'N': drawNebu(x,y,mag,type[1],color_str, size_obj(label_field));
X break;
X case 'G': drawGalx(x,y,mag,type[1],color_str, size_obj(label_field));
X break;
X case 'C': drawClus(x,y,mag,type[1],color_str, size_obj(label_field));
X break;
X case 'U':
X drawUnknown(x,y,mag,type[1],color_str, size_obj(label_field));
X break;
X case 'O':
X drawOther(x,y,mag,type[1],color_str, size_obj(label_field));
X break;
X case 'V':
X case 'A':
X case 'I':
X break;
X case '#':
X default:
X break;
X };
X
X
X/*
X * use name or label
X */
X if (draw_text) {
X if (type[0] == 'I')
X D_color(color_str);
X else
X D_color(" ");
X
X if (use_name && obj_name[0]) {
X D_fontsize(NAMESIZE, NAMEFNT);
X D_text(x+x_nameoffset, y+y_nameoffset, obj_name, FALSE);
X } else if (use_lbl &&
X ((label_field[0] != ' ') || (label_field[1] != ' '))) {
X D_fontsize(LBLSIZE, LBLFNT);
X D_text(x+x_lbloffset, y+y_lbloffset, label_field, TRUE);
X }
X/* If you want to mag label other objects, change this */
X if (use_mag && (type[0] == 'S')) {
X sprintf(magstr, "%02d", (int)(mag*10.0+0.5));
X D_fontsize(MAGSIZE, MAGFNT);
X D_text(x+x_magoffset, y+y_magoffset, magstr, FALSE);
X }
X }
X}
X
XdrawStar(x, y, mag, type, color)
X int x, y;
X double mag;
X char type, *color;
X{
X switch ((int)(mag+0.5))
X {
X case -1:
X case 0:
X D_text(x, y, "O", FALSE);
X break;
X case 1:
X D_text(x, y, "*", FALSE);
X break;
X case 2:
X D_text(x, y, "o", FALSE);
X break;
X case 3:
X D_text(x, y, "-", FALSE);
X break;
X case 4:
X D_text(x, y, ",", FALSE);
X break;
X default:
X D_text(x, y, ".", FALSE);
X break;
X }
X}
X
XdrawPlan(x, y, mag, pcode, color, plansize)
X int x,y;
X double mag;
X char pcode, *color;
X long plansize;
X
X{
X D_text(x, y, "+", FALSE);
X}
X
XdrawGalx(x, y, mag, type, color, nebsize)
X int x, y;
X double mag;
X char type, *color;
X long nebsize; /* -1 should give default size */
X{
X D_text(x, y, "@", FALSE);
X}
X
XdrawClus(x, y, mag, type, color, nebsize)
X int x, y;
X double mag;
X char type, *color;
X long nebsize; /* -1 should give default size */
X{
X D_text(x, y, "%", FALSE);
X}
X
XdrawNebu(x, y, mag, type, color, nebsize)
X int x, y;
X double mag;
X char type, *color;
X long nebsize; /* -1 should give default size */
X{
X D_text(x, y, "~", FALSE);
X}
X
XdrawUnknown(x, y, mag, type, color, nebsize)
X int x, y;
X double mag;
X char type, *color;
X long nebsize; /* -1 should give default size */
X{
X D_text(x, y, "?", FALSE);
X}
X
XdrawOther(x, y, mag, type, color, nebsize)
X int x, y;
X double mag;
X char type, *color;
X long nebsize; /* -1 should give default size */
X{
X D_text(x, y, "#", FALSE);
X}
X
X/* Functions for areas, drawn as lines for now */
X/* Move to (x, y) to begin an area */
XD_areamove(x, y)
X int x, y;
X{
X D_move(x, y);
X}
X
X/* Add a segment to the area border */
XD_areaadd(x, y)
X int x, y;
X{
X D_draw(x, y, SOLID);
X}
X
X/* Fill the area, after adding the last segment */
XD_areafill(x, y)
X int x, y;
X{
X D_draw(x, y, SOLID);
X}
X
X
X/* Variables of positioning are here */
X#define L_TIL 220
X#define L_STIL 185
X
X#define L_LMAR1 40
X#define L_LMAR2 65
X#define L_LTEXT 95
X#define L_RMAR1 205
X#define L_RMAR2 230
X#define L_RTEXT 260
X
X#define L_LINE1 150
X#define L_LINE2 125
X#define L_LINE3 100
X#define L_LINE4 75
X#define L_LINE5 50
X#define L_LINE6 25
X
X
Xchartlegend(win)
X mapwindow *win;
X{
X char ras[20], dls[20], outstr[40];
X if (!title[0]) title = "LEGEND";
X rastr(ras, win->racen);
X declstr(dls, win->dlcen);
X
X if (win->map_type != FULLPAGEMAP) {
X sprintf(outstr, "(%s,%s lim: %2.1f)", ras, dls, win->maglim);
X D_fontsize(TITLESIZE, TITLEFNT); D_text(L_LMAR1, L_TIL, title, FALSE);
X D_fontsize(SUBTLSIZE, SUBTLFNT); D_text(L_LMAR1, L_STIL, outstr, FALSE);
X
X drawStar(L_LMAR2, L_LINE1, 0.0, 'S', " ");
X D_fontsize(12, NAMEFNT);
X D_text(L_LTEXT, L_LINE1,"<0.5", FALSE);
X if (win->maglim >= 0.5)
X {
X drawStar(L_RMAR2, L_LINE1, 1.0, 'S', " ");
X D_fontsize(10, NAMEFNT);
X D_text( L_RTEXT, L_LINE1,"<1.5", FALSE);
X }
X if (win->maglim >= 1.5)
X {
X drawStar(L_LMAR2, L_LINE2, 2.0, 'S', " ");
X D_fontsize( 9, NAMEFNT);
X D_text(L_LTEXT, L_LINE2,"<2.5", FALSE);
X }
X if (win->maglim >= 2.5)
X {
X drawStar(L_RMAR2, L_LINE2, 3.0, 'S', " ");
X D_fontsize( 8, NAMEFNT);
X D_text(L_RTEXT, L_LINE2,"<3.5", FALSE);
X }
X if (win->maglim >= 3.5)
X {
X drawStar(L_LMAR2, L_LINE3, 4.0, 'S', " ");
X D_fontsize( 7, NAMEFNT);
X D_text(L_LTEXT, L_LINE3,"<4.5", FALSE);
X }
X if (win->maglim > 4.5)
X {
X drawStar(L_RMAR2, L_LINE3, 5.0, 'S', " ");
X D_fontsize( 6, NAMEFNT);
X D_text(L_RTEXT, L_LINE3,">4.5", FALSE);
X }
X
X D_fontsize(10, NAMEFNT);
X D_text(L_LTEXT,L_LINE4,"double", FALSE);
X drawStar(L_LMAR2,L_LINE4,2.0, 'D', " ");
X D_fontsize(10, NAMEFNT);
X D_text(L_RTEXT,L_LINE4,"variable",FALSE);
X drawStar(L_RMAR2,L_LINE4,2.0, 'V', " ");
X
X D_fontsize(10, NAMEFNT);
X D_text(L_LTEXT,L_LINE5,"planet", FALSE);
X drawPlan(L_LMAR2,L_LINE5,1.0, ' ', " ", (long) -1);
X
X D_fontsize(10, NAMEFNT);
X D_text(L_RTEXT,L_LINE5,"galaxy", FALSE);
X drawGalx(L_RMAR2,L_LINE5,1.0, 'E', " ", (long) -1);
X drawGalx(L_RMAR1,L_LINE5,1.0, 'S', " ", (long) -1);
X
X D_fontsize(10, NAMEFNT);
X D_text(L_LTEXT,L_LINE6,"nebula", FALSE);
X drawNebu(L_LMAR2,L_LINE6,1.0, 'D', " ", (long) -1);
X drawNebu( L_LMAR1,L_LINE6,1.0, 'P', " ", (long) -1);
X
X D_fontsize(10, NAMEFNT);
X D_text(L_RTEXT,L_LINE6,"cluster", FALSE);
X drawClus(L_RMAR2,L_LINE6,1.0, 'O', " ", (long) -1);
X drawClus(L_RMAR1,L_LINE6,1.0, 'G', " ", (long) -1);
X } else {
X D_fontsize(8, NAMEFNT);
X
X sprintf(outstr, "%s: %s,%s lim: %2.1f", title, ras, dls, win->maglim);
X D_text(15, 15, outstr, FALSE);
X }
X}
X
X
X
END_OF_FILE
if test 17440 -ne `wc -c <'starchart/stardsp.c'`; then
echo shar: \"'starchart/stardsp.c'\" unpacked with wrong size!
fi
# end of 'starchart/stardsp.c'
fi
if test -f 'starchart/starsample.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'starchart/starsample.c'\"
else
echo shar: Extracting \"'starchart/starsample.c'\" \(14975 characters\)
sed "s/^X//" >'starchart/starsample.c' <<'END_OF_FILE'
X/*
X * Driver skeleton
X */
X
X/*
X * Produced for starchart 3.0 by Craig Counterman Jan, 1989
X *
X * Copyright (c) 1990 by Craig Counterman. All rights reserved.
X *
X * This software may be redistributed freely, not sold.
X * This copyright notice and disclaimer of warranty must remain
X * unchanged.
X *
X * No representation is made about the suitability of this
X * software for any purpose. It is provided "as is" without express or
X * implied warranty, to the extent permitted by applicable law.
X *
X */
X
Xstatic char rcsid[]="$Header: starsample.c,v 2.3 90/02/19 17:56:56 ccount Exp $";
X
X#include <stdio.h>
X#include <math.h>
X#ifndef SYSV
X#include <strings.h>
X#else
X#include <string.h>
X#endif
X#include <ctype.h>
X#include "star3.h"
X
X/* Externs */
Xextern int g_argc;
Xextern char **g_argv;
X
Xextern char *title; /* Title of page */
X
Xextern mapwindow *mapwin[MAXWINDOWS];
Xextern int numwins;
X
Xextern int cur_function;
Xextern int cur_map_type;
Xextern int cur_map_tag;
Xextern char *cur_tag_field;
X
X/* Set by initxform
X One could use elements of the mapwindow structure,
X but these should be faster for the current window */
Xextern double xf_west, xf_east, xf_north, xf_south, xf_bottom;
Xextern int xf_xcen, xf_ycen, xf_ybot;
Xextern int xf_w_left, xf_w_right, xf_w_top, xf_w_bot;
Xextern double xf_c_scale;
X
X/* Scale multiplier, minimum,
X mangitude change, maximum, for thumbnail,*/
X#define THSMUL 1.2
X#define THSMIN 12.0
X#define THMADJ 2.5
X#define THMMAX 5.0
X
X
X/* Exports */
X
X/* The variables in the first few lines MUST be set by driver */
Xmapwindow fullpage = {
X 880, 700, 20, 65, /* width, height, x and y offsets */
X 5.9, 2.0, 2.05, /* default limiting mags for glyph, name, label */
X
X/* The next several variables SHOULD be set by the driver,
X but are only used by the driver */
X FULLPAGEMAP, /* Type of map: THUMBNAIL may have
X some restrictions */
X 0, /* May be used by driver for whatever */
X "String", /* May be used by driver for whatever */
X
X/* The next several variables may be set by the driver, but the main routines
X may reset them (and the driver routines may then override that) */
X SANSONS, /* Projection mode */
X FALSE, FALSE, /* Draw grids */
X 0.5, 5.0, /* grid step size */
X 0.0, 0.0, /* grid origin */
X
X FALSE, /* Invert (flip north south) */
X};
X
X/* The variables in the first few lines MUST be set by driver */
Xmapwindow mainmap = {
X 880, 500, 20, 265, /* width, height, x and y offsets */
X 5.9, 2.0, 2.05, /* default limiting mags for glyph, name, label */
X
X/* The next several variables SHOULD be set by the driver,
X but are only used by the driver */
X MAINMAP, /* Type of map: THUMBNAIL may have
X some restrictions */
X 0, /* May be used by driver for whatever */
X "String", /* May be used by driver for whatever */
X
X/* The next several variables may be set by the driver, but the main routines
X may reset them (and the driver routines may then override that) */
X SANSONS, /* Projection mode */
X FALSE, FALSE, /* Draw grids */
X 0.5, 5.0, /* grid step size */
X 0.0, 0.0, /* grid origin */
X
X FALSE, /* Invert (flip north south) */
X};
X
X
X/* The variables in the first few lines MUST be set by driver */
Xmapwindow thumbmap = {
X 480, 195, 420, 35, /* width, height, x and y offsets */
X 3.0+THMADJ, 1.0+THMADJ, 2.05+THMADJ,
X /* default limiting mags for glyph, name, label */
X
X/* The next several variables SHOULD be set by the driver,
X but are only used by the driver */
X THUMBNAIL, /* Type of map: THUMBNAIL may have
X some restrictions */
X 0, /* May be used by driver for whatever */
X "String", /* May be used by driver for whatever */
X
X/* The next several variables may be set by the driver, but the main routines
X may reset them (and the driver routines may then override that) */
X SANSONS, /* Projection mode */
X FALSE, FALSE, /* Draw grids */
X 0.5, 5.0, /* grid step size */
X 0.0, 0.0, /* grid origin */
X
X FALSE, /* Invert (flip north south) */
X};
X
X/* h & v tick text controls */
Xint htick_lim = 2;
Xint htext_lim = 80;
Xint htext_xoff = 2;
Xint htext_yoff = 17;
Xint vtick_lim = 2;
Xint vtext_lim = 20;
Xint vtext_xoff = 24;
Xint vtext_yoff = 0;
X
X/* Scale multiplier, minimum,
X mangitude change, maximum, for thumbnail,*/
Xdouble th_smul=THSMUL;
Xdouble th_smin=THSMIN;
Xdouble th_madj=THMADJ;
Xdouble th_mmax=THMMAX;
X
X#define MAX(a,b) ((a)>(b)?(a):(b))
X#define MIN(a,b) ((a)<(b)?(a):(b))
X
X
X/* Device control argument */
XD_control_arg(s)
Xchar *s;
X{
X int i = 0;
X int c;
X
X while (c = s[i++]) switch (c) {
X default:
X break;
X }
X}
X
X/* Open the device */
XD_open()
X{
X
X return TRUE ; /* open successful */
X}
X
X
X/* Close the device */
XD_close()
X{
X}
X
X
X/* Move to (x, y) */
XD_move(x, y)
X int x, y;
X{
X}
X
X
X/* Draw a line of style line_style from the current point to (x, y) */
X/* Note, this replaces vecdraw vecdrawdot and vecdrawhyph */
XD_draw(x, y, line_style)
X int x, y;
X int line_style; /* SOLID, DOTTED, DASHED, etc. */
X{
X}
X/* This routine is encouraged to look at the extern cur_funtion
X and change the line style drawn as desired */
X
X
X/* Move to (x1, y1) then draw a line of style line_style to (x2, y2) */
XD_movedraw(x1, y1, x2, y2, line_style)
X int x1, y1, x2, y2;
X int line_style; /* SOLID, DOTTED, DASHED, etc. */
X{
X}
X
X
X/* Set the color to be used for lines and text */
X/* color_str is a 2 char (+ '\0') string containing
X a specification for a color,
X e.g. "G2" for the color of a star of spectral class G2, or "r7" for
X red, level seven. The interpretation of the color string is left to
X the device driver */
XD_color(color_str)
X char *color_str;
X{
X switch (color_str[0]) {
X case 'O':
X break;
X case 'B':
X break;
X case 'A':
X break;
X case 'F':
X break;
X case 'G':
X break;
X case 'K':
X break;
X case 'M':
X break;
X case 'R':
X case 'N':
X case 'S':
X break;
X case 'r':
X case 'g':
X case 'b':
X case 'y':
X case 'c':
X case 'p':
X case 'o':
X case 'w':
X break;
X case ' ':
X default:
X break;
X }
X}
X
X
X/* Set the font and font size to be used for text. */
X/* Note order of args */
XD_fontsize(fsize, font)
X int fsize; /* Size of font */
X int font; /* e.g. TIMES, HELV, TIMES+ITALIC */
X{
X}
X/* This routine is encouraged to look at the extern cur_funtion
X and change the font used as desired */
X
X
X/* Display text string str at x,y, in current font and font size.
X if star_lbl is TRUE, string is a star label, use
X greek characters (if possible) */
XD_text(x, y, str, star_lbl)
X int x, y;
X char *str;
X int star_lbl;
X{
X if (star_lbl) {
X /* remove leading spaces */
X while (*str == ' ') str++;
X /* can't display greek characters */
X }
X}
X
X
X/* Return input coordinate in device coords where there are pointing devices */
XD_inxy(x, y)
X int *x, *y;
X{
X}
X
X
X/* Put non-displayed comment in output. Allowed in postscript, but
X few other drivers will be able to support this. */
XD_comment(str)
X char *str;
X{
X/*
X fprintf(stderr, "%s\n", str);
X*/
X}
X
X
X/**
XHigher level functions
X**/
X
X/* Point sizes for font calls */
X#define TITLESIZE 16
X#define SUBTLSIZE 12
X#define NAMESIZE 10
X#define LBLSIZE 8
X#define MAGSIZE 8
X
X/* Fonts for font calls */
X#define NAMEFNT TIMESROMAN
X#define LBLFNT HELV
X#define MAGFNT COURIER
X#define TITLEFNT TIMESBOLD
X#define SUBTLFNT TIMESROMAN
X
Xint x_nameoffset = 10, y_nameoffset = 0;
Xint x_lbloffset = 0, y_lbloffset = 10;
Xint x_magoffset = 7, y_magoffset = -15;
X
X
X/* Interface Function */
X/* Draw object at x, y. properties set by other parameters */
Xdrawobj(x, y, mag, type, color_str, label_field, con_str, obj_name,
X comment_str, file_line,
X draw_glyph, draw_text, use_lbl, use_name, use_mag)
X
X int x, y;
X double mag; /* Magnitude of object */
X char *type; /* 2 chars, object code and subcode */
X char *color_str; /* 2 chars, spectral type for stars,
X color code otherwise */
X char *label_field; /* 2 chars, Bayer or flamsteed for stars,
X size in seconds for nebulae and
X planets */
X char *con_str; /* 3 chars, the constellation the object is in */
X char *obj_name; /* Name of object */
X char *comment_str; /* Comment field */
X char *file_line; /* The full line from the file,
X containing the above if it is in
X standard format */
X int draw_glyph; /* Draw object symbol */
X int draw_text; /* Draw text */
X int use_lbl; /* Label object with the label_field string */
X int use_name; /* Label object with the obj_name string */
X int use_mag; /* Label object with a 2 or 3 character string
X containing the magnitude * 10 without
X decimal point */
X{
X char magstr[10];
X
X/*fprintf(stderr, "%d %d %f <%s> <%s> <%s> <%s> <%s> <%s> <%s>\n", x, y, mag,
X type, color_str, label_field, con_str, obj_name, comment_str,
X file_line);*/
X
X if (draw_glyph) switch(type[0])
X {
X case 'S': drawStar(x,y,mag,type[1],color_str);
X break;
X
X/* If your driver can't support scaled nebulae, galaxies, etc.,
X you can remove the calls to size_obj, and the corresponding
X argument in the function */
X
X case 'P': drawPlan(x,y,mag,type[1],color_str, size_obj(label_field));
X break;
X case 'N': drawNebu(x,y,mag,type[1],color_str, size_obj(label_field));
X break;
X case 'G': drawGalx(x,y,mag,type[1],color_str, size_obj(label_field));
X break;
X case 'C': drawClus(x,y,mag,type[1],color_str, size_obj(label_field));
X break;
X case 'U':
X drawUnknown(x,y,mag,type[1],color_str, size_obj(label_field));
X break;
X case 'O':
X drawOther(x,y,mag,type[1],color_str, size_obj(label_field));
X break;
X case 'V':
X default:
X break;
X }
X/*
X * use name or label
X */
X if (draw_text) {
X if (use_name && obj_name[0]) {
X D_fontsize(NAMESIZE, NAMEFNT);
X D_text(x+x_nameoffset, y+y_nameoffset, obj_name, FALSE);
X } else if (use_lbl &&
X ((label_field[0] != ' ') || (label_field[1] != ' '))) {
X D_fontsize(LBLSIZE, LBLFNT);
X D_text(x+x_lbloffset, y+y_lbloffset, label_field, TRUE);
X }
X/* If you want to magnitude label other objects, change this */
X if (use_mag && (type[0] == 'S')) {
X sprintf(magstr, "%02d", (int)(mag*10.0+0.5));
X D_fontsize(MAGSIZE, MAGFNT);
X D_text(x+x_magoffset, y+y_magoffset, magstr, FALSE);
X }
X }
X}
X
XdrawStar(x, y, mag, type, color)
X int x, y;
X double mag;
X char type, *color;
X{
X switch ((int)(mag+0.5))
X {
X case -1:
X case 0:
X case 1:
X case 2:
X case 3:
X case 4:
X break;
X default:
X break;
X }
X}
X
XdrawPlan(x, y, mag, pcode, color, plansize)
X int x,y;
X double mag;
X char pcode, *color;
X long plansize; /* -1 should give default size */
X{
X int diam;
X
X diam = (int) (plansize/(3600.*xf_c_scale)+.5);
X if (diam < 10) /* size of object in device coords */
X diam = 10;
X}
X
XdrawGalx(x, y, mag, type, color, nebsize)
X int x, y;
X double mag;
X char type, *color;
X long nebsize; /* -1 should give default size */
X{
X int diam;
X
X diam = (int) (nebsize/(3600.*xf_c_scale)+.5);
X if (diam < 10) /* size of object in device coords */
X diam = 10;
X}
X
XdrawClus(x, y, mag, type, color, nebsize)
X int x, y;
X double mag;
X char type, *color;
X long nebsize; /* -1 should give default size */
X{
X int diam;
X
X diam = (int) (nebsize/(3600.*xf_c_scale)+.5);
X if (diam < 10) /* size of object in device coords */
X diam = 10;
X}
X
XdrawNebu(x, y, mag, type, color, nebsize)
X int x, y;
X double mag;
X char type, *color;
X long nebsize; /* -1 should give default size */
X{
X int diam;
X
X diam = (int) (nebsize/(3600.*xf_c_scale)+.5);
X if (diam < 10) /* size of object in device coords */
X diam = 10;
X}
X
XdrawUnknown(x, y, mag, type, color, nebsize)
X int x, y;
X double mag;
X char type, *color;
X long nebsize; /* -1 should give default size */
X{
X int diam;
X
X diam = (int) (nebsize/(3600.*xf_c_scale)+.5);
X if (diam < 10) /* size of object in device coords */
X diam = 10;
X}
X
XdrawOther(x, y, mag, type, color, nebsize)
X int x, y;
X double mag;
X char type, *color;
X long nebsize; /* -1 should give default size */
X{
X int diam;
X
X diam = (int) (nebsize/(3600.*xf_c_scale)+.5);
X if (diam < 10) /* size of object in device coords */
X diam = 10;
X}
X
X
X
X/* Variables of positioning are here */
X#define L_TIL 675
X#define L_STIL 575
X
X#define L_LMAR1 150
X#define L_LMAR2 175
X#define L_LTEXT 200
X#define L_RMAR1 600
X#define L_RMAR2 625
X#define L_RTEXT 650
X
X#define L_LINE1 400
X#define L_LINE2 350
X#define L_LINE3 300
X#define L_LINE4 250
X#define L_LINE5 200
X#define L_LINE6 150
X
X
Xchartlegend(win)
X mapwindow *win;
X{
X char ras[20], dls[20], outstr[40];
X if (!title[0]) title = "LEGEND";
X rastr(ras, win->racen);
X declstr(dls, win->dlcen);
X
X if (win->map_type != FULLPAGEMAP) {
X sprintf(outstr, "(%s,%s lim: %2.1f)", ras, dls, win->maglim);
X D_fontsize(TITLESIZE, TITLEFNT); D_text(L_LMAR1, L_TIL, title, FALSE);
X D_fontsize(SUBTLSIZE, SUBTLFNT); D_text(L_LMAR1, L_STIL, outstr, FALSE);
X
X drawStar(L_LMAR2, L_LINE1, 0.0, 'S', " ");
X D_fontsize(12, NAMEFNT);
X D_text(L_LTEXT, L_LINE1,"<0.5", FALSE);
X if (win->maglim >= 0.5)
X {
X drawStar(L_RMAR2, L_LINE1, 1.0, 'S', " ");
X D_fontsize(10, NAMEFNT);
X D_text( L_RTEXT, L_LINE1,"<1.5", FALSE);
X }
X if (win->maglim >= 1.5)
X {
X drawStar(L_LMAR2, L_LINE2, 2.0, 'S', " ");
X D_fontsize( 9, NAMEFNT);
X D_text(L_LTEXT, L_LINE2,"<2.5", FALSE);
X }
X if (win->maglim >= 2.5)
X {
X drawStar(L_RMAR2, L_LINE2, 3.0, 'S', " ");
X D_fontsize( 8, NAMEFNT);
X D_text(L_RTEXT, L_LINE2,"<3.5", FALSE);
X }
X if (win->maglim >= 3.5)
X {
X drawStar(L_LMAR2, L_LINE3, 4.0, 'S', " ");
X D_fontsize( 7, NAMEFNT);
X D_text(L_LTEXT, L_LINE3,"<4.5", FALSE);
X }
X if (win->maglim > 4.5)
X {
X drawStar(L_RMAR2, L_LINE3, 5.0, 'S', " ");
X D_fontsize( 6, NAMEFNT);
X D_text(L_RTEXT, L_LINE3,">4.5", FALSE);
X }
X
X D_fontsize(10, NAMEFNT);
X D_text(L_LTEXT,L_LINE4,"double", FALSE);
X drawStar(L_LMAR2,L_LINE4,2.0, 'D', " ");
X D_fontsize(10, NAMEFNT);
X D_text(L_RTEXT,L_LINE4,"variable",FALSE);
X drawStar(L_RMAR2,L_LINE4,2.0, 'V', " ");
X
X D_fontsize(10, NAMEFNT);
X D_text(L_LTEXT,L_LINE5,"planet", FALSE);
X drawPlan(L_LMAR2,L_LINE5,1.0, ' ', " ", (long) -1);
X
X D_fontsize(10, NAMEFNT);
X D_text(L_RTEXT,L_LINE5,"galaxy", FALSE);
X drawGalx(L_RMAR2,L_LINE5,1.0, 'E', " ", (long) -1);
X drawGalx(L_RMAR1,L_LINE5,1.0, 'S', " ", (long) -1);
X
X D_fontsize(10, NAMEFNT);
X D_text(L_LTEXT,L_LINE6,"nebula", FALSE);
X drawNebu(L_LMAR2,L_LINE6,1.0, 'D', " ", (long) -1);
X drawNebu( L_LMAR1,L_LINE6,1.0, 'P', " ", (long) -1);
X
X D_fontsize(10, NAMEFNT);
X D_text(L_RTEXT,L_LINE6,"cluster", FALSE);
X drawClus(L_RMAR2,L_LINE6,1.0, 'O', " ", (long) -1);
X drawClus(L_RMAR1,L_LINE6,1.0, 'G', " ", (long) -1);
X } else {
X D_fontsize(8, NAMEFNT);
X sprintf(outstr, "%s: %s,%s lim: %2.1f", title, ras, dls, win->maglim);
X D_text(75, 105, outstr, FALSE);
X }
X}
X
X
X
X
X
END_OF_FILE
if test 14975 -ne `wc -c <'starchart/starsample.c'`; then
echo shar: \"'starchart/starsample.c'\" unpacked with wrong size!
fi
# end of 'starchart/starsample.c'
fi
echo shar: End of archive 10 \(of 32\).
cp /dev/null ark10isdone
MISSING=""
for I in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 ; do
if test ! -f ark${I}isdone ; then
MISSING="${MISSING} ${I}"
fi
done
if test "${MISSING}" = "" ; then
echo You have unpacked all 32 archives.
rm -f ark[1-9]isdone ark[1-9][0-9]isdone
else
echo You still need to unpack the following archives:
echo " " ${MISSING}
fi
## End of shell archive.
exit 0
More information about the Comp.sources.misc
mailing list