home *** CD-ROM | disk | FTP | other *** search
/ Garbo / Garbo.cdr / pc / source / star.lzh / star.14 < prev    next >
Encoding:
Text File  |  1990-04-06  |  26.9 KB  |  1,033 lines

  1.  
  2. #! /bin/sh
  3. # This is a shell archive.  Remove anything before this line, then unpack
  4. # it by saving it into a file and typing "sh file".  To overwrite existing
  5. # files, type "sh file -c".  You can also feed this as standard input via
  6. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  7. # will see the following message at the end:
  8. #        "End of archive 14 (of 32)."
  9. # Contents:  starchart/starsunv.c
  10. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  11. if test -f 'starchart/starsunv.c' -a "${1}" != "-c" ; then 
  12.   echo shar: Will not clobber existing file \"'starchart/starsunv.c'\"
  13. else
  14. echo shar: Extracting \"'starchart/starsunv.c'\" \(25159 characters\)
  15. sed "s/^X//" >'starchart/starsunv.c' <<'END_OF_FILE'
  16. X/*
  17. X * Sunview driver for starchart.c 3.0 6/15/89
  18. X *
  19. X * Driver creates sunview window and draws starchart information inside.
  20. X *
  21. X *
  22. X * Copyright (c) 1990 by Craig Counterman. All rights reserved.
  23. X *
  24. X * This software may be redistributed freely, not sold.
  25. X * This copyright notice and disclaimer of warranty must remain
  26. X *    unchanged. 
  27. X *
  28. X * No representation is made about the suitability of this
  29. X * software for any purpose.  It is provided "as is" without express or
  30. X * implied warranty, to the extent permitted by applicable law.
  31. X *
  32. X */
  33. X
  34. X
  35. Xstatic char rcsid[]="$Header: starsunv.c,v 1.8 90/02/19 17:57:03 ccount Exp $";
  36. X
  37. X#include <stdio.h>
  38. X#include <math.h>
  39. X#include <ctype.h>
  40. X#include "star3.h"
  41. X
  42. X#ifndef SYSV
  43. X#include <strings.h>
  44. X#else
  45. X#include <string.h>
  46. X#endif
  47. X
  48. X#include <suntool/sunview.h>
  49. X#include <suntool/canvas.h>
  50. X
  51. Xchar *malloc();
  52. X
  53. X
  54. X
  55. X#ifndef INTERACTIVE_CONTROL
  56. Xchar prog[] = "Starsunv";
  57. X#else
  58. Xextern char prog[];
  59. X#endif
  60. X
  61. X#define BLACK 0
  62. X#define WHITE 1
  63. X#define RED 2
  64. X#define ORANGE 3
  65. X#define YELLOW 4
  66. X#define GREEN 5
  67. X#define CYAN 6
  68. X#define BLUE 7
  69. X#define VIOLET 8
  70. X#define BLUE_WHITE 9
  71. X
  72. X/* Externs */
  73. Xextern int g_argc;
  74. Xextern char **g_argv;
  75. X
  76. Xextern char *title;
  77. X
  78. Xextern mapwindow *mapwin[MAXWINDOWS];
  79. Xextern int numwins;
  80. X
  81. Xextern int cur_function;
  82. Xextern int cur_map_type;
  83. Xextern int cur_map_tag;
  84. Xextern char *cur_tag_field;
  85. X
  86. X
  87. X/* Scale multiplier, minimum,
  88. X   mangitude change, maximum, for thumbnail */
  89. X#define THSMUL 1.2
  90. X#define THSMIN 12.0
  91. X#define THMADJ 2.5
  92. X#define THMMAX 8.0
  93. X
  94. Xmapwindow fullpage = {920, 700, 20, 48,
  95. X                      8.0, 2.0, 2.05, FULLPAGEMAP, 0, "String",
  96. X                      SANSONS, FALSE, FALSE, 0.5, 5.0, 0.0, 0.0, FALSE,};
  97. Xmapwindow mainmap = {920, 480, 20, 268,
  98. X                     8.0, 3.0, 2.05, MAINMAP, 0, "String", 
  99. X                     SANSONS, FALSE, FALSE, 0.5, 5.0, 0.0, 0.0, FALSE,};
  100. Xmapwindow thumbmap = {480, 195, 420, 35, 6.0+THMADJ, 1.0+THMADJ, 2.05+THMADJ,
  101. X                     THUMBNAIL, 0, "String", SANSONS, FALSE, FALSE, 0.5, 5.0,
  102. X                     0.0, 0.0, FALSE,};
  103. X
  104. Xint htick_lim=2;
  105. Xint htext_lim = 80;
  106. Xint htext_xoff = 2;
  107. Xint htext_yoff = 17;
  108. Xint vtick_lim = 2;
  109. Xint vtext_lim = 20;
  110. Xint vtext_xoff = 24;
  111. Xint vtext_yoff = 0;
  112. X
  113. X/* externs for labels */
  114. Xint x_nameoffset = 10, y_nameoffset = 0;
  115. Xint x_lbloffset = 7, y_lbloffset = 0;
  116. Xint x_magoffset = 7, y_magoffset = -10;
  117. X
  118. X/* externs for legend: variables of positioning are here */
  119. Xint l_til=105;
  120. Xint l_stil=85;
  121. X
  122. Xint l_lmar1=25;
  123. Xint l_lmar2=50;
  124. Xint l_ltext=75;
  125. Xint l_rmar1=150;
  126. Xint l_rmar2=175;
  127. Xint l_rtext=200;
  128. X
  129. Xint l_line1=72;
  130. Xint l_line2=60;
  131. Xint l_line3=47;
  132. Xint l_line4=35;
  133. Xint l_line5=22;
  134. Xint l_line6=10;
  135. X
  136. X/* Point sizes for font calls */
  137. Xint titlesize=18;
  138. Xint subtlsize=12;
  139. Xint namesize=10;
  140. Xint lblsize=10;
  141. Xint magsize=8;
  142. X
  143. X/* Fonts for font calls */
  144. Xint namefnt=TIMESROMAN;
  145. Xint lblfnt=TIMESROMAN;
  146. Xint magfnt=COURIER;
  147. Xint titlefnt=TIMESBOLD;
  148. Xint subtlfnt=TIMESROMAN;
  149. X
  150. X/* Scale multiplier, minimum,
  151. X   mangitude change, maximum, for thumbnail,*/
  152. Xdouble th_smul=THSMUL;
  153. Xdouble th_smin=THSMIN;
  154. Xdouble th_madj=THMADJ;
  155. Xdouble th_mmax=THMMAX;
  156. X
  157. X#define MAX(a,b) ((a)>(b)?(a):(b))
  158. X#define MIN(a,b) ((a)<(b)?(a):(b))
  159. X
  160. X
  161. X/* Font names */
  162. Xstatic char *default_font_name = "/usr/lib/fonts/fixedwidthfonts/screen.r.12";
  163. Xstatic char *greek_font_name = "/usr/lib/fonts/fixedwidthfonts/apl.r.10";
  164. Xstatic char *timesroman_font_name = "/usr/lib/fonts/fixedwidthfonts/serif.r.10";
  165. Xstatic char *timesbold_font_name = "/usr/lib/fonts/fixedwidthfonts/serif.r.10";
  166. Xstatic char *timesital_font_name = "/usr/lib/fonts/fixedwidthfonts/serif.r.10";
  167. Xstatic char *timesboldital_font_name = "/usr/lib/fonts/fixedwidthfonts/serif.r.10";
  168. Xstatic char *helv_font_name = "/usr/lib/fonts/fixedwidthfonts/gacha.r.8";
  169. Xstatic char *helvbold_font_name = "/usr/lib/fonts/fixedwidthfonts/gacha.b.8";
  170. Xstatic char *helvital_font_name = "/usr/lib/fonts/fixedwidthfonts/gacha.r.8";
  171. Xstatic char *helvboldital_font_name = "/usr/lib/fonts/fixedwidthfonts/gachs.b.8";
  172. Xstatic char *courier_font_name = "/usr/lib/fonts/fixedwidthfonts/cour.r.10";
  173. Xstatic char *courital_font_name = "/usr/lib/fonts/fixedwidthfonts/cour.r.10";
  174. Xstatic char *courbold_font_name = "/usr/lib/fonts/fixedwidthfonts/cour.b.10";
  175. Xstatic char *couritalbold_font_name = "/usr/lib/fonts/fixedwidthfonts/cour.b.10";
  176. X
  177. X
  178. X/* Sunview things */
  179. XFrame frame;
  180. XCanvas canvas;
  181. XPixwin *pw;
  182. XPr_brush pr_br = { 0 };
  183. XPr_texture dash_tex;
  184. Xshort dash_patts[][3] = {
  185. X  {1, 1, 0},
  186. X  {2, 2, 0},
  187. X  {3, 3, 0},
  188. X  {4, 4, 0},
  189. X  {5, 5, 0},
  190. X  {6, 6, 0},
  191. X  {7, 7, 0},
  192. X  {8, 8, 0},
  193. X  {9, 9, 0},
  194. X  {10, 10, 0}
  195. X};
  196. Xstatic Pixfont *greek_pfont;
  197. X
  198. Xint is_color = TRUE;        /* Is it color? */
  199. Xint is_super_color = TRUE;    /* Is it many color? */
  200. Xint ncolors, star_colors;
  201. Xunsigned int width, height;
  202. Xint draw_color = 1;
  203. X
  204. X/* Device control argument */
  205. XD_control_arg(s)
  206. Xchar *s;
  207. X{
  208. X  int i = 0;
  209. X  int c;
  210. X
  211. X  while (c = s[i++]) switch (c) {
  212. X  case 'm': /* monochrome display */
  213. X    is_color = FALSE;
  214. X  default:
  215. X    break;
  216. X  }
  217. X}
  218. X
  219. X
  220. X#ifndef INTERACTIVE_CONTROL
  221. X
  222. Xvoid
  223. Xmouse_event_proc(window, event, arg)
  224. XWindow window;
  225. XEvent *event;
  226. Xcaddr_t arg;
  227. X{
  228. X  int x, y;
  229. X  int i;
  230. X  double lat, lon, tlat, tlon;
  231. X  char outstr[81];
  232. X  int ra_h, ra_m, ra_s;
  233. X  int de_d, de_m, de_s;
  234. X  char dsign;
  235. X
  236. X  if (event_is_up(event))
  237. X    return;
  238. X
  239. X  x = event_x(event);
  240. X  y = event_y(event);
  241. X
  242. X  switch(event_action(event)) {
  243. X  case MS_LEFT:
  244. X  case MS_RIGHT:
  245. X    if ((i = invxform(x, height - y, &lat, &lon)) >= 0) {
  246. X      if (lon < 0.0) lon += 360.0;
  247. X      tlon = lon / 15.0;
  248. X
  249. X      ra_h = tlon;
  250. X      ra_m = (tlon - ra_h) * 60 + (0.5 / 60);
  251. X      ra_s = (((tlon - ra_h) * 60) - ra_m) * 60 + 0.5;
  252. X
  253. X      if (ra_s >= 60) {ra_s -= 60; ra_m++;};
  254. X      if (ra_m >= 60) {ra_m -= 60; ra_h++;};
  255. X
  256. X
  257. X      if (lat < 0.0) {
  258. X    tlat = -lat;
  259. X    dsign = '-';
  260. X      } else {
  261. X    tlat = lat;
  262. X    dsign = '+';
  263. X      }
  264. X
  265. X      de_d = tlat;
  266. X      de_m = (tlat - de_d) * 60 + (0.5 / 60);
  267. X      de_s = (((tlat - de_d) * 60) - de_m) * 60 + 0.5;
  268. X
  269. X      if (de_s >= 60) {de_s -= 60; de_m++;};
  270. X      if (de_m >= 60) {de_m -= 60; de_d++;};
  271. X
  272. X
  273. X      sprintf(outstr, "RA: %2dh%2dm%2ds   dec: %c%2dd%2dm%2ds",
  274. X          ra_h, ra_m, ra_s, dsign, de_d, de_m, de_s);
  275. X      D_comment(outstr);
  276. X      if (event_action(event) == MS_RIGHT)
  277. X    dblookup(i, lat, lon, 10);
  278. X    }
  279. X    break;
  280. X  default:
  281. X    break;
  282. X  };
  283. X}
  284. X
  285. X
  286. X/* Open the device */
  287. XD_open()
  288. X{
  289. X  unsigned int map_width;
  290. X  double legend_spacing;
  291. X
  292. X  width = 650; height = 768;
  293. X
  294. X  /* Create frame and canvas */
  295. X  frame = window_create(NULL, FRAME, FRAME_LABEL, "Hello there",
  296. X            WIN_HEIGHT, height + 30,
  297. X            WIN_WIDTH, width + 20,
  298. X            0);
  299. X  if (!(frame))
  300. X    return FALSE;
  301. X
  302. X  canvas = window_create(frame, CANVAS,
  303. X             WIN_HEIGHT, height,
  304. X             WIN_WIDTH, width,
  305. X             WIN_EVENT_PROC, mouse_event_proc,
  306. X             0);
  307. X
  308. X
  309. X  window_set(canvas,
  310. X         CANVAS_AUTO_SHRINK, FALSE,
  311. X         CANVAS_AUTO_EXPAND, FALSE,
  312. X         0);
  313. X
  314. X  /* get the canvas pixwin to draw into */
  315. X  pw = canvas_pixwin(canvas);
  316. X
  317. X  is_color &= (pw->pw_pixrect->pr_depth >= 4);
  318. X  is_super_color = is_color & (pw->pw_pixrect->pr_depth >= 6);
  319. X  ncolors = (is_color ? 12 : 2);
  320. X  star_colors = (is_super_color ? 65: 0);
  321. X
  322. X  D_setcolors();
  323. X
  324. X  map_width = width - 75;
  325. X
  326. X  fullpage.width = map_width;
  327. X  fullpage.height = height - 50;
  328. X  fullpage.x_offset = 25;
  329. X  fullpage.y_offset = 25;
  330. X
  331. X  mainmap.width = map_width;
  332. X  mainmap.height = ((height -25 - 25 - 25)*3)/4;
  333. X  mainmap.x_offset = 25;
  334. X  mainmap.y_offset = 25 + (height -25 - 25 - 25)/4 + 25;
  335. X
  336. X  thumbmap.width = map_width/2;
  337. X  thumbmap.height = (height -25 - 25 - 25)/4;
  338. X  thumbmap.x_offset = 25 + map_width/2;
  339. X  thumbmap.y_offset = 25;
  340. X
  341. X  /* Need to adjust label here */
  342. X  /* Want top of l_til to be at top of thumbmap */
  343. X  l_til = thumbmap.height + thumbmap.y_offset - titlesize;
  344. X  /* Space text in legends to fill space.  Leave 10 on bottom.
  345. X     Text totals 6*namesize+subtlsize. */
  346. X
  347. X  legend_spacing = (l_til - 10 - 6*namesize - subtlsize)/7;
  348. X  if (legend_spacing < 2) legend_spacing = 2;
  349. X
  350. X  l_stil = l_til - subtlsize - legend_spacing;
  351. X  l_line1 = l_stil - namesize - legend_spacing;
  352. X  l_line2 = l_line1 - namesize - legend_spacing;
  353. X  l_line3 = l_line2 - namesize - legend_spacing;
  354. X  l_line4 = l_line3 - namesize - legend_spacing;
  355. X  l_line5 = l_line4 - namesize - legend_spacing;
  356. X  l_line6 = l_line5 - namesize - legend_spacing;
  357. X
  358. X  greek_pfont = pf_open(greek_font_name);
  359. X
  360. X  
  361. X  /* Clear to black */
  362. X  {
  363. X    int i;
  364. X    /* I don't underatanmd pw_polygon_2, so won't use it */
  365. X/*
  366. X    for (i = 0; i < width; i++) {
  367. X      pw_vector(pw, i, 0, i, 30, PIX_SRC, 0);
  368. X      pw_vector(pw, i, 30, i, 60, PIX_SRC, 1);
  369. X      pw_vector(pw, i, 60, i, 90, PIX_SRC, 2);
  370. X      pw_vector(pw, i, 90, i, 120, PIX_SRC, 3);
  371. X      pw_vector(pw, i, 120, i, 150, PIX_SRC, 4);
  372. X      pw_vector(pw, i, 150, i, 180, PIX_SRC, 5);
  373. X      pw_vector(pw, i, 180, i, 210, PIX_SRC, 6);
  374. X      pw_vector(pw, i, 210, i, 240, PIX_SRC, 7);
  375. X      pw_vector(pw, i, 240, i, 270, PIX_SRC, 8);
  376. X      pw_vector(pw, i, 270, i, 300, PIX_SRC, 9);
  377. X      pw_vector(pw, i, 300, i, 330, PIX_SRC, 10);
  378. X      pw_vector(pw, i, 330, i, 360, PIX_SRC, 11);
  379. X      pw_vector(pw, i, 360, i, 390, PIX_SRC, 12);
  380. X      pw_vector(pw, i, 390, i, 420, PIX_SRC, 13);
  381. X      pw_vector(pw, i, 420, i, 450, PIX_SRC, 14);
  382. X      pw_vector(pw, i, 450, i, 480, PIX_SRC, 15);
  383. X    }
  384. X*/
  385. X  }
  386. X
  387. X  return TRUE;                /* open successful */
  388. X}
  389. X
  390. X/* Close the device */
  391. XD_close()
  392. X{
  393. X  window_main_loop(frame);
  394. X  exit(1);   
  395. X}
  396. X
  397. X#endif /* not INTERACTIVE_CONTROL */
  398. X
  399. X
  400. X/* Readstar globals */
  401. Xextern double obj_lat, obj_lon, obj_mag;
  402. Xextern char obj_type[3], obj_color[3], obj_label[3];
  403. Xextern char obj_constell[3], obj_name[];
  404. Xextern char *obj_commnt, fileline[];
  405. X
  406. X/* needed by readstar */
  407. Xint (*readfile)();
  408. Xextern char *cur_file_name;
  409. X
  410. Xdblookup(winnum, lat, lon, dpix)
  411. X     int winnum;
  412. X     double lat, lon;
  413. X     int dpix;
  414. X{
  415. X  int i;
  416. X  double delta;
  417. X  double f_east, f_north, f_west, f_south;
  418. X  FILE *file1, *file2;
  419. X  char ibuf[2020], fname[1030], ftypestr[32];
  420. X  int n;
  421. X  int ftype;
  422. X
  423. X  D_comment("Looking for object");
  424. X  
  425. X  delta = mapwin[winnum]->c_scale * dpix;
  426. X
  427. X  for (i = 0; i < mapwin[winnum]->numfiles; i++) {
  428. X    if ((file1 = fopen(mapwin[winnum]->file[i].name, "r")) == NULL) continue;
  429. X
  430. X    cur_file_name = mapwin[winnum]->file[i].name;
  431. X    ftype = mapwin[winnum]->file[i].type;
  432. X    if (mapwin[winnum]->file[i].type == INDEXTYPE) {
  433. X      /* read each line of index file, parse data on the files indexed:
  434. X     region_included file_name
  435. X         use an indexed file if the point is in the region */
  436. X
  437. X      while (!feof(file1)) {
  438. X    fgets(ibuf, 2000, file1);
  439. X    n = sscanf(ibuf, "%lf %lf %lf %lf %1000s %30s\n", &f_east, &f_north,
  440. X           &f_west, &f_south, fname, ftypestr);
  441. X    if ((n != 6) || feof(file1)) continue;
  442. X
  443. X    f_east *= 15.0;
  444. X    f_west *= 15.0;
  445. X
  446. X    if (westof(lon, f_east) && eastof(lon, f_west)
  447. X        && (lat >= f_south) && (lat <= f_north)) {
  448. X      if ((file2 = fopen(fname, "r")) == NULL) {
  449. X        fprintf(stderr, "%s: error, couldn't open '%s' for reading.\n",
  450. X            prog, fname);
  451. X      } else {
  452. X        cur_file_name = fname;
  453. X
  454. X        ftype = tr_fty(ftypestr);
  455. X
  456. X        if (ftype == INDEXTYPE)  {
  457. X          fprintf(stderr,
  458. X  "%s: error, can't use type INDEXTYPE file '%s' from another index file.\n",
  459. X              prog, fname);
  460. X        } else {
  461. X          do_look(file2, ftype, lat, lon, delta);
  462. X        }
  463. X        fclose(file2);
  464. X        cur_file_name = "";
  465. X      }
  466. X    }
  467. X      }
  468. X    } else {
  469. X      do_look(file1, ftype, lat, lon, delta);
  470. X    }
  471. X
  472. X    fclose(file1);
  473. X  };
  474. X
  475. X  D_comment("Done search");
  476. X}
  477. X
  478. Xdo_look(file, ftype, lat, lon, delta)
  479. XFILE *file;
  480. Xint ftype;
  481. Xdouble lat, lon, delta;
  482. X{
  483. X  double dlat, dlon;
  484. X  double tlat, tlon;
  485. X  int ra_h, ra_m, ra_s;
  486. X  int de_d, de_m, de_s;
  487. X  char dsign;
  488. X
  489. X  char outstr[81];
  490. X
  491. X
  492. X  while (!(*readfile)(file, ftype)) {
  493. X    dlat = fabs(obj_lat - lat);
  494. X    dlon = fabs(obj_lon - lon);
  495. X    if ((dlat <= delta) && (dlon <= delta)) {
  496. X      tlon = obj_lon/15.0;
  497. X      ra_h = tlon;
  498. X      ra_m = (tlon - ra_h) * 60 + (0.5 / 60);
  499. X      ra_s = (((tlon - ra_h) * 60) - ra_m) * 60 + 0.5;
  500. X
  501. X      if (ra_s >= 60) {ra_s -= 60; ra_m++;};
  502. X      if (ra_m >= 60) {ra_m -= 60; ra_h++;};
  503. X
  504. X
  505. X      if (obj_lat < 0.0) {
  506. X    tlat = -obj_lat;
  507. X    dsign = '-';
  508. X      } else {
  509. X    tlat = obj_lat;
  510. X    dsign = '+';
  511. X      }
  512. X
  513. X      de_d = tlat;
  514. X      de_m = (tlat - de_d) * 60 + (0.5 / 60);
  515. X      de_s = (((tlat - de_d) * 60) - de_m) * 60 + 0.5;
  516. X
  517. X      if (de_s >= 60) {de_s -= 60; de_m++;};
  518. X      if (de_m >= 60) {de_m -= 60; de_d++;};
  519. X
  520. X
  521. X
  522. X      sprintf(outstr,
  523. X      "%2dh%2dm%2ds %c%2dd%2dm%2ds %5.2f %2s %2s %2s %3s %-25.25s %-14.14s",
  524. X          ra_h, ra_m, ra_s, dsign, de_d, de_m, de_s, obj_mag,
  525. X          obj_type,  obj_color, obj_label, obj_constell,
  526. X          obj_name, obj_commnt);
  527. X      D_comment(outstr);
  528. X    }
  529. X  }
  530. X}
  531. X
  532. X
  533. Xstatic int current_x, current_y;
  534. X
  535. X/* Move to (x, y) */
  536. XD_move(x, y)
  537. X     int x, y;
  538. X{
  539. X  current_x = x; current_y = y;
  540. X}
  541. X
  542. X
  543. Xstatic int curr_lsty = -1;
  544. X/* Draw a line of style line_style from the current point to (x, y) */
  545. XD_draw(x, y, line_style)
  546. X     int x, y, line_style;
  547. X{
  548. X  int xline_sty;
  549. X  int dashes = 1;
  550. X  Pr_texture *texture;
  551. X
  552. X  switch (cur_function) {
  553. X  case CHRTOUTLN:
  554. X  case CHRTHTICK:
  555. X  case CHRTVTICK:
  556. X    xline_sty = SOLID;
  557. X    dashes = 1;
  558. X    break;
  559. X  case GRID_RA:
  560. X  case GRID_DEC:
  561. X    xline_sty = DASHED;
  562. X    dashes = 4;
  563. X    break;
  564. X  case ECLIPT:
  565. X    xline_sty = DASHED;
  566. X    dashes = 1;
  567. X    break;
  568. X  case CONSTBOUND:
  569. X    xline_sty = DASHED;
  570. X    dashes = 6;
  571. X    break;
  572. X  case CONSTPATTRN:
  573. X    xline_sty = DASHED;
  574. X    dashes = 8;
  575. X    break;
  576. X  case CONSTNAME:
  577. X  case CHARTFILE:
  578. X  default:
  579. X    switch (line_style) {
  580. X    case SOLID:
  581. X    case VECSOLID:
  582. X      xline_sty = SOLID;
  583. X      dashes = 1;
  584. X      break;
  585. X    case DASHED:
  586. X    case VECDASH:
  587. X      xline_sty = DASHED;
  588. X      dashes = 5;
  589. X      break;
  590. X    case DOTTED:
  591. X    case VECDOT:
  592. X      xline_sty = DASHED;
  593. X      dashes = 1;
  594. X      break;
  595. X    default:
  596. X      xline_sty = SOLID;
  597. X      dashes = 1;
  598. X      break;
  599. X    };
  600. X    break;
  601. X  }
  602. X
  603. X  if (xline_sty == SOLID)  {
  604. X    texture = NULL;
  605. X  } else {
  606. X    texture = &dash_tex;
  607. X
  608. X    texture->pattern = dash_patts[dashes];
  609. X  }
  610. X
  611. X  pw_line(pw, current_x, (int)(height - current_y),
  612. X      x, (int)(height - y), &pr_br, texture,
  613. X      PIX_SRC | PIX_COLOR(draw_color));
  614. X
  615. X
  616. X  curr_lsty = xline_sty;
  617. X
  618. X  current_x = x; current_y = y;
  619. X}
  620. X/* This routine is encouraged to look at the extern cur_funtion
  621. X   and change the line style drawn as desired */
  622. X
  623. X
  624. X/* Move to (x1, y1) then draw a line of style line_style to (x2, y2) */
  625. XD_movedraw(x1, y1, x2, y2, line_style)
  626. X     int x1, y1, x2, y2, line_style;
  627. X{
  628. X  D_move(x1, y1);
  629. X  D_draw(x2, y2, line_style);
  630. X}
  631. X
  632. X
  633. Xstatic struct pr_pos areapts[1000];
  634. Xstatic int nareapts;
  635. X/* Move to (x, y) to begin an area */
  636. XD_areamove(x, y)
  637. X     int x, y;
  638. X{
  639. X  nareapts = 0;
  640. X  areapts[nareapts].x = x;
  641. X  areapts[nareapts].y = height - y;
  642. X  nareapts++;
  643. X}
  644. X
  645. X/* Add a segment to the area border */
  646. XD_areaadd(x, y)
  647. X     int x, y;
  648. X{
  649. X  areapts[nareapts].x = x;
  650. X  areapts[nareapts].y = height - y;
  651. X  nareapts++;
  652. X}
  653. X
  654. X/* Fill the area, after adding the last segment */
  655. XD_areafill(x, y)
  656. X     int x, y;
  657. X{
  658. X  areapts[nareapts].x = x;
  659. X  areapts[nareapts].y = height - y;
  660. X  nareapts++;
  661. X
  662. X  pw_polygon_2(pw, 0, 0, 1, &nareapts, areapts, PIX_SRC|PIX_COLOR(draw_color),
  663. X      NULL, 0, 0);
  664. X
  665. X  nareapts = 0;
  666. X}
  667. X
  668. X/* Set the color to be used for lines and text */
  669. X/* color_str is a 2 char (+ '\0') string
  670. X   containing a specification for a color,
  671. X   e.g. "G2" for the color of a star of spectral class G2, or "r7" for
  672. X   red, level seven.  The interpretation of the color string is left to
  673. X   the device driver */
  674. XD_color(color_str)
  675. X     char *color_str;
  676. X{
  677. X  int colr;
  678. X  int class, subclass;
  679. X  static char *table = "OBAFGKMRNSrgbycpow";
  680. X  static int spectra[10] = {
  681. X    BLUE_WHITE, BLUE, WHITE, WHITE, YELLOW, ORANGE, RED, RED, RED};
  682. X
  683. X  static int super_spectra[][10] = {
  684. X    /*         0   1   2   3   4   5   6   7   8   9   */
  685. X    /* O */ { 32, 32, 32, 32, 32, 32, 32, 32, 32, 32 },
  686. X    /* B */ {  0,  1,  2,  3,  3,  4,  4,  4,  5,  6 },
  687. X    /* A */ {  7,  7,  8,  9,  9, 10, 10, 10, 10, 10 },
  688. X    /* F */ { 11, 11, 12, 12, 12, 13, 13, 13, 14, 14 },
  689. X    /* G */ { 15, 15, 15, 15, 15, 16, 16, 16, 16, 16 },
  690. X    /* K */ { 17, 17, 18, 18, 18, 19, 19, 19, 19, 19 },
  691. X    /* M */ { 20, 20, 21, 22, 23, 24, 25, 26, 26, 26 },
  692. X    /* R */ { 27, 27, 27, 28, 28, 28, 28, 28, 29, 30 },
  693. X    /* N */ { 27, 27, 27, 28, 28, 28, 28, 28, 29, 30 },
  694. X    /* S */ { 30, 30, 30, 30, 31, 31, 31, 31, 31, 31 },
  695. X    /* r */ { 33, 33, 33, 34, 34, 34, 35, 35, 35, 36 },
  696. X    /* g */ { 37, 37, 37, 38, 38, 38, 39, 39, 39, 40 },
  697. X    /* b */ { 41, 41, 41, 42, 42, 42, 43, 43, 43, 44 },
  698. X    /* y */ { 45, 45, 45, 46, 46, 46, 47, 47, 47, 48 },
  699. X    /* c */ { 49, 49, 49, 50, 50, 50, 51, 51, 51, 52 },
  700. X    /* p */ { 53, 53, 53, 54, 54, 54, 55, 55, 55, 56 },
  701. X    /* o */ { 57, 57, 57, 58, 58, 58, 59, 59, 59, 60 },
  702. X    /* w */ { 61, 61, 61, 62, 62, 62, 63, 63, 63, 64 }
  703. X      };
  704. X
  705. X  if (!is_color) return;
  706. X
  707. X  class = 0;
  708. X  while (table[class] && (table[class] != color_str[0])) class++;
  709. X
  710. X  if (is_super_color) {
  711. X    subclass = isdigit(color_str[1]) ? color_str[1] - '0' : 0;
  712. X    colr = table[class] ? (10+super_spectra[class][subclass]) : WHITE;
  713. X  } else
  714. X    colr = table[class] ? spectra[class] : WHITE;
  715. X
  716. X  draw_color = colr;
  717. X}
  718. X
  719. X
  720. Xstatic int current_font = -1, current_fsize = -1;
  721. Xstatic Pixfont *curr_pfont;
  722. X
  723. X/* Set the font and font size to be used for text. */
  724. X/* Note order of args */
  725. XD_fontsize(fsize, font)
  726. X     int font, fsize;
  727. X{
  728. X  char *fontname, readname[50];
  729. X
  730. X  switch(cur_function) {
  731. X  case CHRTOUTLN:
  732. X    break;
  733. X  case CHRTHTICK:
  734. X  case CHRTVTICK:
  735. X    font = TIMESBOLD;
  736. X    break;
  737. X  case GRID_RA:
  738. X  case GRID_DEC:
  739. X  case ECLIPT:
  740. X    break;
  741. X  case CONSTBOUND:
  742. X  case CONSTPATTRN:
  743. X    break;
  744. X  case CONSTNAME:
  745. X    font = HELVITAL;
  746. X    break;
  747. X  case CHARTFILE:
  748. X  case CURNTFONT:
  749. X  default:
  750. X    break;
  751. X  }
  752. X
  753. X  if ((font == current_font) && (fsize == current_fsize)) return;
  754. X
  755. X  switch(font)
  756. X    {
  757. X    case TIMESROMAN: fontname = timesroman_font_name; break;
  758. X    case TIMESBOLD: fontname = timesbold_font_name; break;
  759. X    case TIMESITAL: fontname = timesital_font_name; break;
  760. X    case TIMESBOLDITAL: fontname = timesboldital_font_name; break;
  761. X    case HELV: fontname = helv_font_name; break;
  762. X    case HELVBOLD: fontname = helvbold_font_name; break;
  763. X    case HELVITAL: fontname = helvital_font_name; break;
  764. X    case HELVBOLDITAL: fontname = helvboldital_font_name; break;
  765. X    case COURIER: fontname = courier_font_name; break;
  766. X    case COURITAL: fontname = courital_font_name; break;
  767. X    case COURBOLD: fontname = courbold_font_name; break;
  768. X    case COURITALBOLD: fontname = couritalbold_font_name; break;
  769. X    }
  770. X
  771. X  current_font = font;
  772. X  current_fsize = fsize;
  773. X
  774. X  curr_pfont = pf_open(fontname);
  775. X}
  776. X/* This routine is encouraged to look at the extern cur_funtion
  777. X   and change the font used as desired */
  778. X
  779. X
  780. Xstatic char  *intable = " 0123456789abgdezh@iklmnEoprstuOx%w";
  781. Xstatic char *outtable = " 0123456789abgdezhqiklmnxoprstujcyw";
  782. X/* Display text string str at x,y, in current font and font size.
  783. X   if star_lbl is TRUE, string is a star label, use
  784. X      greek characters (if possible) */
  785. XD_text(x, y, s, star_lbl)
  786. X     int x, y;
  787. X     char *s;
  788. X     int star_lbl;
  789. X{
  790. X  char ch;
  791. X  int i, j;
  792. X  int use_greek = FALSE;
  793. X
  794. X  if (star_lbl) {
  795. X    if (isgreek(s[0]) && (isdigit(s[1]) || (s[1] == ' '))) {
  796. X      /* Greek if first character is greek encoded,
  797. X     and the second is space or a digit */
  798. X      use_greek = TRUE;
  799. X#ifdef OLD_GREEK
  800. X      /* Translate yaleformat greek encoding to Symbol font encoding */
  801. X      i = 0;
  802. X      while (ch = s[i])
  803. X    {
  804. X      j = 0;
  805. X      while (intable[j] && (intable[j] != ch)) j++;
  806. X      s[i] = intable[j] ? outtable[j] : s[i];
  807. X      /* If not in translation table, leave it alone */
  808. X      i++;
  809. X    }
  810. X#endif
  811. X    } else { /* Star label, but not greek */
  812. X    /* remove leading spaces */
  813. X    while (*s == ' ') s++;
  814. X    }
  815. X  }
  816. X
  817. X  pw_ttext(pw, x, height - y, PIX_SRC|PIX_COLOR(draw_color),
  818. X      use_greek ? greek_pfont : curr_pfont, s);
  819. X}
  820. X
  821. Xisgreek(c)
  822. Xchar c;
  823. X{
  824. X  char *cp;
  825. X
  826. X#ifdef OLD_GREEK
  827. X  cp = "abgdezh@iklmnEoprstuOx%w";
  828. X#else
  829. X  cp = "abgdezhqiklmnxoprstujcyw";
  830. X#endif
  831. X  while (*cp && (*cp != c)) cp++;
  832. X  return (*cp != '\0'); /* True if letter was in greek string */
  833. X}
  834. X
  835. X
  836. X/* Return input coordinate in device coords where there are pointing devices */
  837. XD_inxy(x, y)
  838. X     int *x, *y;
  839. X{
  840. X}
  841. X
  842. X
  843. X/* Put non-displayed comment in output.  Allowed in postscript, but
  844. X   few other drivers will be able to support this. */ 
  845. X#ifndef INTERACTIVE_CONTROL
  846. XD_comment(str)
  847. X     char *str;
  848. X{
  849. X  fprintf(stdout, "%s\r\n", str);
  850. X}
  851. X#endif
  852. X
  853. X
  854. X
  855. X/**
  856. XHigher level functions
  857. X**/
  858. X
  859. Xdrawlen(x, y, dx, dy, len)
  860. X     int x,y, dx, dy, len;
  861. X{
  862. X  buildlines(x + dx, (int) (height - (y+dy)),
  863. X         x+dx+len, (int)(height - (y+dy)));
  864. X}
  865. X
  866. X
  867. XD_setcolors()
  868. X{
  869. X  static int data[][3] = {
  870. X    {   0,   0,   0 },   /* BLACK */
  871. X    { 255, 255, 255 },   /* WHITE */
  872. X    { 255,   0,   0 },   /* RED */
  873. X    { 255, 100,   0 },   /* ORANGE */
  874. X    { 255, 255,   0 },   /* YELLOW */
  875. X    {   0, 255,   0 },   /* GREEN */
  876. X    {   0, 255, 255 },   /* CYAN */
  877. X    {   0,   0, 255 },   /* BLUE */
  878. X    { 255,   0, 255 },   /* VIOLET */
  879. X    { 130, 130, 255 },   /* BLUE_WHITE */
  880. X  };
  881. X  static double super_data[][3] = {
  882. X    /*  Red             Green          Blue    Name by which type is known */
  883. X    { 0.38937,        0.46526,        0.79493 },    /* B0 */
  884. X    { 0.39501,        0.47146,        0.78847 },    /* B1 */
  885. X    { 0.40103,        0.47792,        0.78151 },    /* B2 */
  886. X    { 0.40640,        0.48355,        0.77526 },    /* B3 */
  887. X    { 0.41341,        0.49071,        0.76701 },    /* B5 */
  888. X    { 0.43251,        0.50914,        0.74412 },    /* B8 */
  889. X    { 0.44342,        0.51897,        0.73079 },    /* B9 */
  890. X    { 0.45181,        0.52618,        0.72042 },    /* A0 */
  891. X    { 0.46931,        0.54026,        0.69847 },    /* A2 */
  892. X    { 0.47958,        0.54792,        0.68541 },    /* A3 */
  893. X    { 0.48538,        0.55205,        0.67797 },    /* A5 */
  894. X    { 0.50879,        0.56731,        0.64752 },    /* F0 */
  895. X    { 0.51732,        0.57231,        0.63627 },    /* F2 */
  896. X    { 0.52348,        0.57573,        0.62810 },    /* F5 */
  897. X    { 0.54076,        0.58447,        0.60496 },    /* F8 */
  898. X    { 0.54853,        0.58799,        0.59446 },    /* G0 */
  899. X    { 0.56951,        0.59623,        0.56584 },    /* G5 */
  900. X    { 0.58992,        0.60244,        0.53765 },    /* K0 */
  901. X    { 0.61098,        0.60693,        0.50828 },    /* K2 */
  902. X    { 0.63856,        0.60977,        0.46950 },    /* K5 */
  903. X    { 0.68698,        0.60595,        0.40110 },    /* M0 */
  904. X    { 0.72528,        0.59434,        0.34744 },    /* M2 */
  905. X    { 0.75182,        0.58144,        0.31097 },    /* M3 */
  906. X    { 0.78033,        0.56272,        0.27282 },    /* M4 */
  907. X    { 0.81066,        0.53676,        0.23394 },    /* M5 */
  908. X    { 0.84247,        0.50195,        0.19570 },    /* M6 */
  909. X    { 0.87512,        0.45667,        0.16004 },    /* M7 */
  910. X    { 0.71033,        0.59983,        0.36829 },    /* N0 */
  911. X    { 0.78625,        0.55816,        0.26507 },    /* N3 */
  912. X    { 0.93792,        0.33011,        0.10649 },    /* N8 */
  913. X    { 0.94897,        0.29906,        0.10012 },    /* N9 */
  914. X    { 0.79832,        0.54811,        0.24950 },    /* S4 */
  915. X    { 0.38241,        0.45743,        0.80282 },    /* O  */
  916. X  };
  917. X  static struct {u_char r, g, b} other_colrs[] = {
  918. X    { 0x80, 0, 0},
  919. X    { 0xc0, 0, 0},
  920. X    { 0xe0, 0, 0},
  921. X    { 0xff, 0, 0},
  922. X    { 0x0, 0x80, 0},
  923. X    { 0x0, 0xc0, 0},
  924. X    { 0x0, 0xe0, 0},
  925. X    { 0x0, 0xff, 0},
  926. X    { 0x0, 0x0, 0x80},
  927. X    { 0x0, 0x0, 0xc0},
  928. X    { 0x0, 0x0, 0xe0},
  929. X    { 0x0, 0x0, 0xff},
  930. X    { 0x80, 0x80, 0x0},
  931. X    { 0xc0, 0xc0, 0x0},
  932. X    { 0xe0, 0xe0, 0x0},
  933. X    { 0xff, 0xff, 0x0},
  934. X    { 0x0, 0x80, 0x80},
  935. X    { 0x0, 0xc0, 0xc0},
  936. X    { 0x0, 0xe0, 0xe0},
  937. X    { 0x0, 0xff, 0xff},
  938. X    { 0x80, 0x0, 0x80},
  939. X    { 0xc0, 0x0, 0xc0},
  940. X    { 0xe0, 0x0, 0xe0},
  941. X    { 0xff, 0x0, 0xff},
  942. X    { 0x80, 0x40, 0x00},
  943. X    { 0xc0, 0x60, 0x00},
  944. X    { 0xe0, 0x70, 0x00},
  945. X    { 0xff, 0x80, 0x00},
  946. X    { 0x80, 0x80, 0x80},
  947. X    { 0xc0, 0xc0, 0xc0},
  948. X    { 0xe0, 0xe0, 0xe0},
  949. X    { 0xff, 0xff, 0xff}
  950. X  };
  951. X  u_char red[255], green[255], blue[255];
  952. X  double max_colr;
  953. X  int i;
  954. X  static int plane_colors[] = { 1, 2, 4, 8, 16, 32, 64, 128, 256};
  955. X
  956. X
  957. X  for (i=0; i< 256; i++) {
  958. X    red[i] = 0;
  959. X    green[i] = 0;
  960. X    blue[i] = 0;
  961. X  };
  962. X
  963. X  for (i=0; i<=9; i++) {
  964. X    red[i] = data[i][0];
  965. X    green[i] = data[i][1];
  966. X    blue[i] = data[i][2];
  967. X  };
  968. X
  969. X  if (is_super_color) {
  970. X    for (i=0; i<=32; i++) {
  971. X      max_colr = super_data[i][0];
  972. X      max_colr = super_data[i][1] > max_colr ? super_data[i][1] : max_colr;
  973. X      max_colr = super_data[i][2] > max_colr ? super_data[i][2] : max_colr;
  974. X      red[i+10] = (int) 255*super_data[i][0] / max_colr;
  975. X      green[i+10] = (int) 255*super_data[i][1] /max_colr;
  976. X      blue[i+10] = (int) 255*super_data[i][2] /max_colr;
  977. X    }
  978. X
  979. X    for (i = 33; i <= 64; i++) {
  980. X      red[i+10] = other_colrs[i-33].r;
  981. X      green[i+10] = other_colrs[i-33].g;
  982. X      blue[i+10] = other_colrs[i-33].b;
  983. X    };
  984. X  }
  985. X
  986. X  i = plane_colors[pw->pw_pixrect->pr_depth];
  987. X  red[i-1] = blue[i-1] = green[i-1] = 255;
  988. X
  989. X  pw_setcmsname(pw, "starcolors");
  990. X  pw_putcolormap(pw, 0, plane_colors[pw->pw_pixrect->pr_depth],
  991. X         red, green, blue);
  992. X}
  993. X
  994. X
  995. X
  996. X#ifndef INTERACTIVE_CONTROL
  997. Xbuildlines(x1, y1, x2, y2)
  998. X     int x1, y1, x2, y2;
  999. X{
  1000. X  pw_line(pw, x1, y1, x2, y2, &pr_br, NULL,
  1001. X      PIX_SRC | PIX_COLOR(draw_color));
  1002. X}
  1003. X
  1004. X
  1005. X#endif /* not INTERACTIVE_CONTROL */
  1006. X
  1007. X
  1008. END_OF_FILE
  1009. if test 25159 -ne `wc -c <'starchart/starsunv.c'`; then
  1010.     echo shar: \"'starchart/starsunv.c'\" unpacked with wrong size!
  1011. fi
  1012. # end of 'starchart/starsunv.c'
  1013. fi
  1014. echo shar: End of archive 14 \(of 32\).
  1015. cp /dev/null ark14isdone
  1016. MISSING=""
  1017. 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
  1018.     if test ! -f ark${I}isdone ; then
  1019.     MISSING="${MISSING} ${I}"
  1020.     fi
  1021. done
  1022. if test "${MISSING}" = "" ; then
  1023.     echo You have unpacked all 32 archives.
  1024.     rm -f ark[1-9]isdone ark[1-9][0-9]isdone
  1025. else
  1026.     echo You still need to unpack the following archives:
  1027.     echo "        " ${MISSING}
  1028. fi
  1029. ##  End of shell archive.
  1030. exit 0
  1031.  
  1032.  
  1033.