v11i042: starchart 3.2 Part 14/32
ccount at ATHENA.MIT.EDU
ccount at ATHENA.MIT.EDU
Mon Mar 26 09:55:23 AEST 1990
Posting-number: Volume 11, Issue 42
Submitted-by: ccount at ATHENA.MIT.EDU
Archive-name: starchart/part14
[Sorry for the delay; compiler confusion after the latest uunet swap caused
my programs to hang. And I'm at the point where it's impossible for me to
avoid duplicate archive names manually. ++bsa]
#! /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 14 (of 32)."
# Contents: starchart/starsunv.c
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f 'starchart/starsunv.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'starchart/starsunv.c'\"
else
echo shar: Extracting \"'starchart/starsunv.c'\" \(25159 characters\)
sed "s/^X//" >'starchart/starsunv.c' <<'END_OF_FILE'
X/*
X * Sunview driver for starchart.c 3.0 6/15/89
X *
X * Driver creates sunview window and draws starchart information inside.
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
X
Xstatic char rcsid[]="$Header: starsunv.c,v 1.8 90/02/19 17:57:03 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 <suntool/sunview.h>
X#include <suntool/canvas.h>
X
Xchar *malloc();
X
X
X
X#ifndef INTERACTIVE_CONTROL
Xchar prog[] = "Starsunv";
X#else
Xextern char prog[];
X#endif
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/* Externs */
Xextern int g_argc;
Xextern char **g_argv;
X
Xextern char *title;
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 8.0
X
Xmapwindow fullpage = {920, 700, 20, 48,
X 8.0, 2.0, 2.05, FULLPAGEMAP, 0, "String",
X SANSONS, FALSE, FALSE, 0.5, 5.0, 0.0, 0.0, FALSE,};
Xmapwindow mainmap = {920, 480, 20, 268,
X 8.0, 3.0, 2.05, MAINMAP, 0, "String",
X SANSONS, FALSE, FALSE, 0.5, 5.0, 0.0, 0.0, FALSE,};
Xmapwindow thumbmap = {480, 195, 420, 35, 6.0+THMADJ, 1.0+THMADJ, 2.05+THMADJ,
X THUMBNAIL, 0, "String", SANSONS, FALSE, FALSE, 0.5, 5.0,
X 0.0, 0.0, FALSE,};
X
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 = 0;
Xint x_magoffset = 7, y_magoffset = -10;
X
X/* externs for legend: variables of positioning are here */
Xint l_til=105;
Xint l_stil=85;
X
Xint l_lmar1=25;
Xint l_lmar2=50;
Xint l_ltext=75;
Xint l_rmar1=150;
Xint l_rmar2=175;
Xint l_rtext=200;
X
Xint l_line1=72;
Xint l_line2=60;
Xint l_line3=47;
Xint l_line4=35;
Xint l_line5=22;
Xint l_line6=10;
X
X/* Point sizes for font calls */
Xint titlesize=18;
Xint subtlsize=12;
Xint namesize=10;
Xint lblsize=10;
Xint magsize=8;
X
X/* Fonts for font calls */
Xint namefnt=TIMESROMAN;
Xint lblfnt=TIMESROMAN;
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
X/* Font names */
Xstatic char *default_font_name = "/usr/lib/fonts/fixedwidthfonts/screen.r.12";
Xstatic char *greek_font_name = "/usr/lib/fonts/fixedwidthfonts/apl.r.10";
Xstatic char *timesroman_font_name = "/usr/lib/fonts/fixedwidthfonts/serif.r.10";
Xstatic char *timesbold_font_name = "/usr/lib/fonts/fixedwidthfonts/serif.r.10";
Xstatic char *timesital_font_name = "/usr/lib/fonts/fixedwidthfonts/serif.r.10";
Xstatic char *timesboldital_font_name = "/usr/lib/fonts/fixedwidthfonts/serif.r.10";
Xstatic char *helv_font_name = "/usr/lib/fonts/fixedwidthfonts/gacha.r.8";
Xstatic char *helvbold_font_name = "/usr/lib/fonts/fixedwidthfonts/gacha.b.8";
Xstatic char *helvital_font_name = "/usr/lib/fonts/fixedwidthfonts/gacha.r.8";
Xstatic char *helvboldital_font_name = "/usr/lib/fonts/fixedwidthfonts/gachs.b.8";
Xstatic char *courier_font_name = "/usr/lib/fonts/fixedwidthfonts/cour.r.10";
Xstatic char *courital_font_name = "/usr/lib/fonts/fixedwidthfonts/cour.r.10";
Xstatic char *courbold_font_name = "/usr/lib/fonts/fixedwidthfonts/cour.b.10";
Xstatic char *couritalbold_font_name = "/usr/lib/fonts/fixedwidthfonts/cour.b.10";
X
X
X/* Sunview things */
XFrame frame;
XCanvas canvas;
XPixwin *pw;
XPr_brush pr_br = { 0 };
XPr_texture dash_tex;
Xshort dash_patts[][3] = {
X {1, 1, 0},
X {2, 2, 0},
X {3, 3, 0},
X {4, 4, 0},
X {5, 5, 0},
X {6, 6, 0},
X {7, 7, 0},
X {8, 8, 0},
X {9, 9, 0},
X {10, 10, 0}
X};
Xstatic Pixfont *greek_pfont;
X
Xint is_color = TRUE; /* Is it color? */
Xint is_super_color = TRUE; /* Is it many color? */
Xint ncolors, star_colors;
Xunsigned int width, height;
Xint draw_color = 1;
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 case 'm': /* monochrome display */
X is_color = FALSE;
X default:
X break;
X }
X}
X
X
X#ifndef INTERACTIVE_CONTROL
X
Xvoid
Xmouse_event_proc(window, event, arg)
XWindow window;
XEvent *event;
Xcaddr_t arg;
X{
X int x, y;
X int i;
X double lat, lon, tlat, tlon;
X char outstr[81];
X int ra_h, ra_m, ra_s;
X int de_d, de_m, de_s;
X char dsign;
X
X if (event_is_up(event))
X return;
X
X x = event_x(event);
X y = event_y(event);
X
X switch(event_action(event)) {
X case MS_LEFT:
X case MS_RIGHT:
X if ((i = invxform(x, height - y, &lat, &lon)) >= 0) {
X if (lon < 0.0) lon += 360.0;
X tlon = lon / 15.0;
X
X ra_h = tlon;
X ra_m = (tlon - ra_h) * 60 + (0.5 / 60);
X ra_s = (((tlon - ra_h) * 60) - ra_m) * 60 + 0.5;
X
X if (ra_s >= 60) {ra_s -= 60; ra_m++;};
X if (ra_m >= 60) {ra_m -= 60; ra_h++;};
X
X
X if (lat < 0.0) {
X tlat = -lat;
X dsign = '-';
X } else {
X tlat = lat;
X dsign = '+';
X }
X
X de_d = tlat;
X de_m = (tlat - de_d) * 60 + (0.5 / 60);
X de_s = (((tlat - de_d) * 60) - de_m) * 60 + 0.5;
X
X if (de_s >= 60) {de_s -= 60; de_m++;};
X if (de_m >= 60) {de_m -= 60; de_d++;};
X
X
X sprintf(outstr, "RA: %2dh%2dm%2ds dec: %c%2dd%2dm%2ds",
X ra_h, ra_m, ra_s, dsign, de_d, de_m, de_s);
X D_comment(outstr);
X if (event_action(event) == MS_RIGHT)
X dblookup(i, lat, lon, 10);
X }
X break;
X default:
X break;
X };
X}
X
X
X/* Open the device */
XD_open()
X{
X unsigned int map_width;
X double legend_spacing;
X
X width = 650; height = 768;
X
X /* Create frame and canvas */
X frame = window_create(NULL, FRAME, FRAME_LABEL, "Hello there",
X WIN_HEIGHT, height + 30,
X WIN_WIDTH, width + 20,
X 0);
X if (!(frame))
X return FALSE;
X
X canvas = window_create(frame, CANVAS,
X WIN_HEIGHT, height,
X WIN_WIDTH, width,
X WIN_EVENT_PROC, mouse_event_proc,
X 0);
X
X
X window_set(canvas,
X CANVAS_AUTO_SHRINK, FALSE,
X CANVAS_AUTO_EXPAND, FALSE,
X 0);
X
X /* get the canvas pixwin to draw into */
X pw = canvas_pixwin(canvas);
X
X is_color &= (pw->pw_pixrect->pr_depth >= 4);
X is_super_color = is_color & (pw->pw_pixrect->pr_depth >= 6);
X ncolors = (is_color ? 12 : 2);
X star_colors = (is_super_color ? 65: 0);
X
X D_setcolors();
X
X map_width = width - 75;
X
X fullpage.width = map_width;
X fullpage.height = height - 50;
X fullpage.x_offset = 25;
X fullpage.y_offset = 25;
X
X mainmap.width = map_width;
X mainmap.height = ((height -25 - 25 - 25)*3)/4;
X mainmap.x_offset = 25;
X mainmap.y_offset = 25 + (height -25 - 25 - 25)/4 + 25;
X
X thumbmap.width = map_width/2;
X thumbmap.height = (height -25 - 25 - 25)/4;
X thumbmap.x_offset = 25 + map_width/2;
X thumbmap.y_offset = 25;
X
X /* Need to adjust label here */
X /* Want top of l_til to be at top of thumbmap */
X l_til = thumbmap.height + thumbmap.y_offset - titlesize;
X /* Space text in legends to fill space. Leave 10 on bottom.
X Text totals 6*namesize+subtlsize. */
X
X legend_spacing = (l_til - 10 - 6*namesize - subtlsize)/7;
X if (legend_spacing < 2) legend_spacing = 2;
X
X l_stil = l_til - subtlsize - legend_spacing;
X l_line1 = l_stil - namesize - legend_spacing;
X l_line2 = l_line1 - namesize - legend_spacing;
X l_line3 = l_line2 - namesize - legend_spacing;
X l_line4 = l_line3 - namesize - legend_spacing;
X l_line5 = l_line4 - namesize - legend_spacing;
X l_line6 = l_line5 - namesize - legend_spacing;
X
X greek_pfont = pf_open(greek_font_name);
X
X
X /* Clear to black */
X {
X int i;
X /* I don't underatanmd pw_polygon_2, so won't use it */
X/*
X for (i = 0; i < width; i++) {
X pw_vector(pw, i, 0, i, 30, PIX_SRC, 0);
X pw_vector(pw, i, 30, i, 60, PIX_SRC, 1);
X pw_vector(pw, i, 60, i, 90, PIX_SRC, 2);
X pw_vector(pw, i, 90, i, 120, PIX_SRC, 3);
X pw_vector(pw, i, 120, i, 150, PIX_SRC, 4);
X pw_vector(pw, i, 150, i, 180, PIX_SRC, 5);
X pw_vector(pw, i, 180, i, 210, PIX_SRC, 6);
X pw_vector(pw, i, 210, i, 240, PIX_SRC, 7);
X pw_vector(pw, i, 240, i, 270, PIX_SRC, 8);
X pw_vector(pw, i, 270, i, 300, PIX_SRC, 9);
X pw_vector(pw, i, 300, i, 330, PIX_SRC, 10);
X pw_vector(pw, i, 330, i, 360, PIX_SRC, 11);
X pw_vector(pw, i, 360, i, 390, PIX_SRC, 12);
X pw_vector(pw, i, 390, i, 420, PIX_SRC, 13);
X pw_vector(pw, i, 420, i, 450, PIX_SRC, 14);
X pw_vector(pw, i, 450, i, 480, PIX_SRC, 15);
X }
X*/
X }
X
X return TRUE; /* open successful */
X}
X
X/* Close the device */
XD_close()
X{
X window_main_loop(frame);
X exit(1);
X}
X
X#endif /* not INTERACTIVE_CONTROL */
X
X
X/* Readstar globals */
Xextern double obj_lat, obj_lon, obj_mag;
Xextern char obj_type[3], obj_color[3], obj_label[3];
Xextern char obj_constell[3], obj_name[];
Xextern char *obj_commnt, fileline[];
X
X/* needed by readstar */
Xint (*readfile)();
Xextern char *cur_file_name;
X
Xdblookup(winnum, lat, lon, dpix)
X int winnum;
X double lat, lon;
X int dpix;
X{
X int i;
X double delta;
X double f_east, f_north, f_west, f_south;
X FILE *file1, *file2;
X char ibuf[2020], fname[1030], ftypestr[32];
X int n;
X int ftype;
X
X D_comment("Looking for object");
X
X delta = mapwin[winnum]->c_scale * dpix;
X
X for (i = 0; i < mapwin[winnum]->numfiles; i++) {
X if ((file1 = fopen(mapwin[winnum]->file[i].name, "r")) == NULL) continue;
X
X cur_file_name = mapwin[winnum]->file[i].name;
X ftype = mapwin[winnum]->file[i].type;
X if (mapwin[winnum]->file[i].type == INDEXTYPE) {
X /* read each line of index file, parse data on the files indexed:
X region_included file_name
X use an indexed file if the point is in the region */
X
X while (!feof(file1)) {
X fgets(ibuf, 2000, file1);
X n = sscanf(ibuf, "%lf %lf %lf %lf %1000s %30s\n", &f_east, &f_north,
X &f_west, &f_south, fname, ftypestr);
X if ((n != 6) || feof(file1)) continue;
X
X f_east *= 15.0;
X f_west *= 15.0;
X
X if (westof(lon, f_east) && eastof(lon, f_west)
X && (lat >= f_south) && (lat <= f_north)) {
X if ((file2 = fopen(fname, "r")) == NULL) {
X fprintf(stderr, "%s: error, couldn't open '%s' for reading.\n",
X prog, fname);
X } else {
X cur_file_name = fname;
X
X ftype = tr_fty(ftypestr);
X
X if (ftype == INDEXTYPE) {
X fprintf(stderr,
X "%s: error, can't use type INDEXTYPE file '%s' from another index file.\n",
X prog, fname);
X } else {
X do_look(file2, ftype, lat, lon, delta);
X }
X fclose(file2);
X cur_file_name = "";
X }
X }
X }
X } else {
X do_look(file1, ftype, lat, lon, delta);
X }
X
X fclose(file1);
X };
X
X D_comment("Done search");
X}
X
Xdo_look(file, ftype, lat, lon, delta)
XFILE *file;
Xint ftype;
Xdouble lat, lon, delta;
X{
X double dlat, dlon;
X double tlat, tlon;
X int ra_h, ra_m, ra_s;
X int de_d, de_m, de_s;
X char dsign;
X
X char outstr[81];
X
X
X while (!(*readfile)(file, ftype)) {
X dlat = fabs(obj_lat - lat);
X dlon = fabs(obj_lon - lon);
X if ((dlat <= delta) && (dlon <= delta)) {
X tlon = obj_lon/15.0;
X ra_h = tlon;
X ra_m = (tlon - ra_h) * 60 + (0.5 / 60);
X ra_s = (((tlon - ra_h) * 60) - ra_m) * 60 + 0.5;
X
X if (ra_s >= 60) {ra_s -= 60; ra_m++;};
X if (ra_m >= 60) {ra_m -= 60; ra_h++;};
X
X
X if (obj_lat < 0.0) {
X tlat = -obj_lat;
X dsign = '-';
X } else {
X tlat = obj_lat;
X dsign = '+';
X }
X
X de_d = tlat;
X de_m = (tlat - de_d) * 60 + (0.5 / 60);
X de_s = (((tlat - de_d) * 60) - de_m) * 60 + 0.5;
X
X if (de_s >= 60) {de_s -= 60; de_m++;};
X if (de_m >= 60) {de_m -= 60; de_d++;};
X
X
X
X sprintf(outstr,
X "%2dh%2dm%2ds %c%2dd%2dm%2ds %5.2f %2s %2s %2s %3s %-25.25s %-14.14s",
X ra_h, ra_m, ra_s, dsign, de_d, de_m, de_s, obj_mag,
X obj_type, obj_color, obj_label, obj_constell,
X obj_name, obj_commnt);
X D_comment(outstr);
X }
X }
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; current_y = y;
X}
X
X
Xstatic int curr_lsty = -1;
X/* Draw a line of style line_style from the current point to (x, y) */
XD_draw(x, y, line_style)
X int x, y, line_style;
X{
X int xline_sty;
X int dashes = 1;
X Pr_texture *texture;
X
X switch (cur_function) {
X case CHRTOUTLN:
X case CHRTHTICK:
X case CHRTVTICK:
X xline_sty = SOLID;
X dashes = 1;
X break;
X case GRID_RA:
X case GRID_DEC:
X xline_sty = DASHED;
X dashes = 4;
X break;
X case ECLIPT:
X xline_sty = DASHED;
X dashes = 1;
X break;
X case CONSTBOUND:
X xline_sty = DASHED;
X dashes = 6;
X break;
X case CONSTPATTRN:
X xline_sty = DASHED;
X dashes = 8;
X break;
X case CONSTNAME:
X case CHARTFILE:
X default:
X switch (line_style) {
X case SOLID:
X case VECSOLID:
X xline_sty = SOLID;
X dashes = 1;
X break;
X case DASHED:
X case VECDASH:
X xline_sty = DASHED;
X dashes = 5;
X break;
X case DOTTED:
X case VECDOT:
X xline_sty = DASHED;
X dashes = 1;
X break;
X default:
X xline_sty = SOLID;
X dashes = 1;
X break;
X };
X break;
X }
X
X if (xline_sty == SOLID) {
X texture = NULL;
X } else {
X texture = &dash_tex;
X
X texture->pattern = dash_patts[dashes];
X }
X
X pw_line(pw, current_x, (int)(height - current_y),
X x, (int)(height - y), &pr_br, texture,
X PIX_SRC | PIX_COLOR(draw_color));
X
X
X curr_lsty = xline_sty;
X
X current_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
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, line_style;
X{
X D_move(x1, y1);
X D_draw(x2, y2, line_style);
X}
X
X
Xstatic struct pr_pos areapts[1000];
Xstatic int nareapts;
X/* Move to (x, y) to begin an area */
XD_areamove(x, y)
X int x, y;
X{
X nareapts = 0;
X areapts[nareapts].x = x;
X areapts[nareapts].y = height - y;
X nareapts++;
X}
X
X/* Add a segment to the area border */
XD_areaadd(x, y)
X int x, y;
X{
X areapts[nareapts].x = x;
X areapts[nareapts].y = height - y;
X nareapts++;
X}
X
X/* Fill the area, after adding the last segment */
XD_areafill(x, y)
X int x, y;
X{
X areapts[nareapts].x = x;
X areapts[nareapts].y = height - y;
X nareapts++;
X
X pw_polygon_2(pw, 0, 0, 1, &nareapts, areapts, PIX_SRC|PIX_COLOR(draw_color),
X NULL, 0, 0);
X
X nareapts = 0;
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 int colr;
X int class, subclass;
X static char *table = "OBAFGKMRNSrgbycpow";
X static int spectra[10] = {
X BLUE_WHITE, BLUE, WHITE, WHITE, YELLOW, ORANGE, RED, RED, RED};
X
X static int super_spectra[][10] = {
X /* 0 1 2 3 4 5 6 7 8 9 */
X /* O */ { 32, 32, 32, 32, 32, 32, 32, 32, 32, 32 },
X /* B */ { 0, 1, 2, 3, 3, 4, 4, 4, 5, 6 },
X /* A */ { 7, 7, 8, 9, 9, 10, 10, 10, 10, 10 },
X /* F */ { 11, 11, 12, 12, 12, 13, 13, 13, 14, 14 },
X /* G */ { 15, 15, 15, 15, 15, 16, 16, 16, 16, 16 },
X /* K */ { 17, 17, 18, 18, 18, 19, 19, 19, 19, 19 },
X /* M */ { 20, 20, 21, 22, 23, 24, 25, 26, 26, 26 },
X /* R */ { 27, 27, 27, 28, 28, 28, 28, 28, 29, 30 },
X /* N */ { 27, 27, 27, 28, 28, 28, 28, 28, 29, 30 },
X /* S */ { 30, 30, 30, 30, 31, 31, 31, 31, 31, 31 },
X /* r */ { 33, 33, 33, 34, 34, 34, 35, 35, 35, 36 },
X /* g */ { 37, 37, 37, 38, 38, 38, 39, 39, 39, 40 },
X /* b */ { 41, 41, 41, 42, 42, 42, 43, 43, 43, 44 },
X /* y */ { 45, 45, 45, 46, 46, 46, 47, 47, 47, 48 },
X /* c */ { 49, 49, 49, 50, 50, 50, 51, 51, 51, 52 },
X /* p */ { 53, 53, 53, 54, 54, 54, 55, 55, 55, 56 },
X /* o */ { 57, 57, 57, 58, 58, 58, 59, 59, 59, 60 },
X /* w */ { 61, 61, 61, 62, 62, 62, 63, 63, 63, 64 }
X };
X
X if (!is_color) return;
X
X class = 0;
X while (table[class] && (table[class] != color_str[0])) class++;
X
X if (is_super_color) {
X subclass = isdigit(color_str[1]) ? color_str[1] - '0' : 0;
X colr = table[class] ? (10+super_spectra[class][subclass]) : WHITE;
X } else
X colr = table[class] ? spectra[class] : WHITE;
X
X draw_color = colr;
X}
X
X
Xstatic int current_font = -1, current_fsize = -1;
Xstatic Pixfont *curr_pfont;
X
X/* Set the font and font size to be used for text. */
X/* Note order of args */
XD_fontsize(fsize, font)
X int font, fsize;
X{
X char *fontname, readname[50];
X
X switch(cur_function) {
X case CHRTOUTLN:
X break;
X case CHRTHTICK:
X case CHRTVTICK:
X font = TIMESBOLD;
X break;
X case GRID_RA:
X case GRID_DEC:
X case ECLIPT:
X break;
X case CONSTBOUND:
X case CONSTPATTRN:
X break;
X case CONSTNAME:
X font = HELVITAL;
X break;
X case CHARTFILE:
X case CURNTFONT:
X default:
X break;
X }
X
X if ((font == current_font) && (fsize == current_fsize)) return;
X
X switch(font)
X {
X case TIMESROMAN: fontname = timesroman_font_name; break;
X case TIMESBOLD: fontname = timesbold_font_name; break;
X case TIMESITAL: fontname = timesital_font_name; break;
X case TIMESBOLDITAL: fontname = timesboldital_font_name; break;
X case HELV: fontname = helv_font_name; break;
X case HELVBOLD: fontname = helvbold_font_name; break;
X case HELVITAL: fontname = helvital_font_name; break;
X case HELVBOLDITAL: fontname = helvboldital_font_name; break;
X case COURIER: fontname = courier_font_name; break;
X case COURITAL: fontname = courital_font_name; break;
X case COURBOLD: fontname = courbold_font_name; break;
X case COURITALBOLD: fontname = couritalbold_font_name; break;
X }
X
X current_font = font;
X current_fsize = fsize;
X
X curr_pfont = pf_open(fontname);
X}
X/* This routine is encouraged to look at the extern cur_funtion
X and change the font used as desired */
X
X
Xstatic char *intable = " 0123456789abgdezh at iklmnEoprstuOx%w";
Xstatic char *outtable = " 0123456789abgdezhqiklmnxoprstujcyw";
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, s, star_lbl)
X int x, y;
X char *s;
X int star_lbl;
X{
X char ch;
X int i, j;
X int use_greek = FALSE;
X
X if (star_lbl) {
X if (isgreek(s[0]) && (isdigit(s[1]) || (s[1] == ' '))) {
X /* Greek if first character is greek encoded,
X and the second is space or a digit */
X use_greek = TRUE;
X#ifdef OLD_GREEK
X /* Translate yaleformat greek encoding to Symbol font encoding */
X i = 0;
X while (ch = s[i])
X {
X j = 0;
X while (intable[j] && (intable[j] != ch)) j++;
X s[i] = intable[j] ? outtable[j] : s[i];
X /* If not in translation table, leave it alone */
X i++;
X }
X#endif
X } else { /* Star label, but not greek */
X /* remove leading spaces */
X while (*s == ' ') s++;
X }
X }
X
X pw_ttext(pw, x, height - y, PIX_SRC|PIX_COLOR(draw_color),
X use_greek ? greek_pfont : curr_pfont, s);
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/* 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. */
X#ifndef INTERACTIVE_CONTROL
XD_comment(str)
X char *str;
X{
X fprintf(stdout, "%s\r\n", str);
X}
X#endif
X
X
X
X/**
XHigher level functions
X**/
X
Xdrawlen(x, y, dx, dy, len)
X int x,y, dx, dy, len;
X{
X buildlines(x + dx, (int) (height - (y+dy)),
X x+dx+len, (int)(height - (y+dy)));
X}
X
X
XD_setcolors()
X{
X static int data[][3] = {
X { 0, 0, 0 }, /* BLACK */
X { 255, 255, 255 }, /* WHITE */
X { 255, 0, 0 }, /* RED */
X { 255, 100, 0 }, /* ORANGE */
X { 255, 255, 0 }, /* YELLOW */
X { 0, 255, 0 }, /* GREEN */
X { 0, 255, 255 }, /* CYAN */
X { 0, 0, 255 }, /* BLUE */
X { 255, 0, 255 }, /* VIOLET */
X { 130, 130, 255 }, /* BLUE_WHITE */
X };
X static double super_data[][3] = {
X /* Red Green Blue Name by which type is known */
X { 0.38937, 0.46526, 0.79493 }, /* B0 */
X { 0.39501, 0.47146, 0.78847 }, /* B1 */
X { 0.40103, 0.47792, 0.78151 }, /* B2 */
X { 0.40640, 0.48355, 0.77526 }, /* B3 */
X { 0.41341, 0.49071, 0.76701 }, /* B5 */
X { 0.43251, 0.50914, 0.74412 }, /* B8 */
X { 0.44342, 0.51897, 0.73079 }, /* B9 */
X { 0.45181, 0.52618, 0.72042 }, /* A0 */
X { 0.46931, 0.54026, 0.69847 }, /* A2 */
X { 0.47958, 0.54792, 0.68541 }, /* A3 */
X { 0.48538, 0.55205, 0.67797 }, /* A5 */
X { 0.50879, 0.56731, 0.64752 }, /* F0 */
X { 0.51732, 0.57231, 0.63627 }, /* F2 */
X { 0.52348, 0.57573, 0.62810 }, /* F5 */
X { 0.54076, 0.58447, 0.60496 }, /* F8 */
X { 0.54853, 0.58799, 0.59446 }, /* G0 */
X { 0.56951, 0.59623, 0.56584 }, /* G5 */
X { 0.58992, 0.60244, 0.53765 }, /* K0 */
X { 0.61098, 0.60693, 0.50828 }, /* K2 */
X { 0.63856, 0.60977, 0.46950 }, /* K5 */
X { 0.68698, 0.60595, 0.40110 }, /* M0 */
X { 0.72528, 0.59434, 0.34744 }, /* M2 */
X { 0.75182, 0.58144, 0.31097 }, /* M3 */
X { 0.78033, 0.56272, 0.27282 }, /* M4 */
X { 0.81066, 0.53676, 0.23394 }, /* M5 */
X { 0.84247, 0.50195, 0.19570 }, /* M6 */
X { 0.87512, 0.45667, 0.16004 }, /* M7 */
X { 0.71033, 0.59983, 0.36829 }, /* N0 */
X { 0.78625, 0.55816, 0.26507 }, /* N3 */
X { 0.93792, 0.33011, 0.10649 }, /* N8 */
X { 0.94897, 0.29906, 0.10012 }, /* N9 */
X { 0.79832, 0.54811, 0.24950 }, /* S4 */
X { 0.38241, 0.45743, 0.80282 }, /* O */
X };
X static struct {u_char r, g, b} other_colrs[] = {
X { 0x80, 0, 0},
X { 0xc0, 0, 0},
X { 0xe0, 0, 0},
X { 0xff, 0, 0},
X { 0x0, 0x80, 0},
X { 0x0, 0xc0, 0},
X { 0x0, 0xe0, 0},
X { 0x0, 0xff, 0},
X { 0x0, 0x0, 0x80},
X { 0x0, 0x0, 0xc0},
X { 0x0, 0x0, 0xe0},
X { 0x0, 0x0, 0xff},
X { 0x80, 0x80, 0x0},
X { 0xc0, 0xc0, 0x0},
X { 0xe0, 0xe0, 0x0},
X { 0xff, 0xff, 0x0},
X { 0x0, 0x80, 0x80},
X { 0x0, 0xc0, 0xc0},
X { 0x0, 0xe0, 0xe0},
X { 0x0, 0xff, 0xff},
X { 0x80, 0x0, 0x80},
X { 0xc0, 0x0, 0xc0},
X { 0xe0, 0x0, 0xe0},
X { 0xff, 0x0, 0xff},
X { 0x80, 0x40, 0x00},
X { 0xc0, 0x60, 0x00},
X { 0xe0, 0x70, 0x00},
X { 0xff, 0x80, 0x00},
X { 0x80, 0x80, 0x80},
X { 0xc0, 0xc0, 0xc0},
X { 0xe0, 0xe0, 0xe0},
X { 0xff, 0xff, 0xff}
X };
X u_char red[255], green[255], blue[255];
X double max_colr;
X int i;
X static int plane_colors[] = { 1, 2, 4, 8, 16, 32, 64, 128, 256};
X
X
X for (i=0; i< 256; i++) {
X red[i] = 0;
X green[i] = 0;
X blue[i] = 0;
X };
X
X for (i=0; i<=9; i++) {
X red[i] = data[i][0];
X green[i] = data[i][1];
X blue[i] = data[i][2];
X };
X
X if (is_super_color) {
X for (i=0; i<=32; i++) {
X max_colr = super_data[i][0];
X max_colr = super_data[i][1] > max_colr ? super_data[i][1] : max_colr;
X max_colr = super_data[i][2] > max_colr ? super_data[i][2] : max_colr;
X red[i+10] = (int) 255*super_data[i][0] / max_colr;
X green[i+10] = (int) 255*super_data[i][1] /max_colr;
X blue[i+10] = (int) 255*super_data[i][2] /max_colr;
X }
X
X for (i = 33; i <= 64; i++) {
X red[i+10] = other_colrs[i-33].r;
X green[i+10] = other_colrs[i-33].g;
X blue[i+10] = other_colrs[i-33].b;
X };
X }
X
X i = plane_colors[pw->pw_pixrect->pr_depth];
X red[i-1] = blue[i-1] = green[i-1] = 255;
X
X pw_setcmsname(pw, "starcolors");
X pw_putcolormap(pw, 0, plane_colors[pw->pw_pixrect->pr_depth],
X red, green, blue);
X}
X
X
X
X#ifndef INTERACTIVE_CONTROL
Xbuildlines(x1, y1, x2, y2)
X int x1, y1, x2, y2;
X{
X pw_line(pw, x1, y1, x2, y2, &pr_br, NULL,
X PIX_SRC | PIX_COLOR(draw_color));
X}
X
X
X#endif /* not INTERACTIVE_CONTROL */
X
X
END_OF_FILE
if test 25159 -ne `wc -c <'starchart/starsunv.c'`; then
echo shar: \"'starchart/starsunv.c'\" unpacked with wrong size!
fi
# end of 'starchart/starsunv.c'
fi
echo shar: End of archive 14 \(of 32\).
cp /dev/null ark14isdone
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