home *** CD-ROM | disk | FTP | other *** search
/ Garbo / Garbo.cdr / pc / source / star.lzh / star.29 < prev    next >
Encoding:
Text File  |  1990-04-06  |  42.5 KB  |  1,487 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 29 (of 32)."
  9. # Contents:  starchart/starX11.c
  10. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  11. if test -f 'starchart/starX11.c' -a "${1}" != "-c" ; then 
  12.   echo shar: Will not clobber existing file \"'starchart/starX11.c'\"
  13. else
  14. echo shar: Extracting \"'starchart/starX11.c'\" \(40722 characters\)
  15. sed "s/^X//" >'starchart/starX11.c' <<'END_OF_FILE'
  16. X/*
  17. X * X11 driver for starchart.c 3.0 mainline 4/17/88
  18. X *
  19. X * Driver creates X11 window and draws starchart information inside.
  20. X * Intially window size is variable, but it stays constant once it's
  21. X * mapped.  It handles expose events, even while it's drawing.
  22. X * Includes glyphs for variable stars.
  23. X *
  24. X *
  25. X * Portions Copyright (c) 1989 by Joe Wang (joe@athena.mit.edu)
  26. X *
  27. X * Copyright (c) 1990 by Craig Counterman. All rights reserved.
  28. X *
  29. X * This software may be redistributed freely, not sold.
  30. X * This copyright notice and disclaimer of warranty must remain
  31. X *    unchanged. 
  32. X *
  33. X * No representation is made about the suitability of this
  34. X * software for any purpose.  It is provided "as is" without express or
  35. X * implied warranty, to the extent permitted by applicable law.
  36. X *
  37. X */
  38. X
  39. Xstatic char rcsid[]="$Header: starX11.c,v 2.16 90/02/19 17:53:06 ccount Exp $";
  40. X
  41. X#include <stdio.h>
  42. X#include <math.h>
  43. X#include <ctype.h>
  44. X#include "star3.h"
  45. X
  46. X#ifndef SYSV
  47. X#include <strings.h>
  48. X#else
  49. X#include <string.h>
  50. X#endif
  51. X
  52. X#include <X11/cursorfont.h>
  53. X#include <X11/Intrinsic.h>
  54. X#include <X11/Xlib.h>
  55. X#include <X11/Xutil.h>
  56. X
  57. Xchar *malloc();
  58. X
  59. X/* X items */
  60. XDisplay *display;            /* connection to display server */
  61. Xint screen_num;
  62. XScreen screen;
  63. XWindow root, window;         /* window to graphics in */
  64. XDrawable draw_into;
  65. XColormap default_cmap;       /* colormap */
  66. XGC default_GC;               /* graphics context */
  67. XXFontStruct *default_font;   /* default font */
  68. XXFontStruct *greek_font;     /* Greek font */
  69. XPixmap backup;               /* backup for expose events */
  70. XPixel black, white, foreground, background;
  71. XPixel *pixels;             /* color map cells */
  72. XPixel *star_pixels;         /* color map cells for super color stars */
  73. Xint ncolors, star_colors;
  74. XXEvent event;             /* event structure */
  75. XXGCValues values_GC;         /* modify GC */
  76. Xunsigned int width, height;
  77. X
  78. XBoolean reverse;
  79. X
  80. XBool use_backup = FALSE;
  81. XBool hide_drawing = FALSE;
  82. XBool post_preview = FALSE;
  83. XBool post_landscape = FALSE;
  84. X#ifdef USE_X_DASHES
  85. XBool use_x_dashes = TRUE;
  86. X#else
  87. XBool use_x_dashes = FALSE;
  88. X#endif
  89. XBool is_color = TRUE;        /* Is it color? */
  90. XBool is_super_color = TRUE;    /* Is it many color? */
  91. X
  92. X
  93. Xint Xargc = 1;
  94. Xchar *Xargv[40];
  95. X
  96. X
  97. X
  98. X#ifdef STARX11
  99. Xchar prog[] = "StarX11";
  100. X#else
  101. Xextern char prog[];
  102. X#endif
  103. X
  104. X#include "icon.h"
  105. X
  106. X#define BLACK 0
  107. X#define WHITE 1
  108. X#define RED 2
  109. X#define ORANGE 3
  110. X#define YELLOW 4
  111. X#define GREEN 5
  112. X#define CYAN 6
  113. X#define BLUE 7
  114. X#define VIOLET 8
  115. X#define BLUE_WHITE 9
  116. X
  117. X/* Externs */
  118. Xextern int g_argc;
  119. Xextern char **g_argv;
  120. X
  121. Xextern char *title;
  122. X
  123. Xextern mapwindow *mapwin[MAXWINDOWS];
  124. Xextern int numwins;
  125. X
  126. Xextern int cur_function;
  127. Xextern int cur_map_type;
  128. Xextern int cur_map_tag;
  129. Xextern char *cur_tag_field;
  130. X
  131. X
  132. X/* Scale multiplier, minimum,
  133. X   mangitude change, maximum, for thumbnail */
  134. X#define THSMUL 1.2
  135. X#define THSMIN 12.0
  136. X#define THMADJ 2.5
  137. X#define THMMAX 8.0
  138. X
  139. Xmapwindow fullpage = {920, 700, 20, 48,
  140. X                      8.0, 3.0, 2.05, FULLPAGEMAP, 0, "String",
  141. X                      SANSONS, FALSE, FALSE, 7.5, 5.0, 0.0, 0.0, FALSE,};
  142. Xmapwindow mainmap = {920, 480, 20, 268,
  143. X                     8.0, 3.0, 2.05, MAINMAP, 0, "String", 
  144. X                     SANSONS, FALSE, FALSE, 7.5, 5.0, 0.0, 0.0, FALSE,};
  145. Xmapwindow thumbmap = {480, 195, 420, 35, 6.2+THMADJ, 1.0+THMADJ, 2.05+THMADJ,
  146. X                     THUMBNAIL, 0, "String", SANSONS, FALSE, FALSE, 7.5, 5.0,
  147. X                     0.0, 0.0, FALSE,};
  148. X
  149. Xint htick_lim = 2;
  150. Xint htext_lim = 37;
  151. Xint htext_xoff = 2;
  152. Xint htext_yoff = 12;
  153. Xint vtick_lim = 2;
  154. Xint vtext_lim = 12;
  155. Xint vtext_xoff = 16;
  156. Xint vtext_yoff = 0;
  157. X
  158. X/* externs for labels */
  159. Xint x_nameoffset = 10, y_nameoffset = 0;
  160. Xint x_lbloffset = 7, y_lbloffset = 0;
  161. Xint x_magoffset = 7, y_magoffset = -10;
  162. X
  163. X/* externs for legend: variables of positioning are here */
  164. Xint l_til=105;
  165. Xint l_stil=85;
  166. X
  167. Xint l_lmar1=25;
  168. Xint l_lmar2=50;
  169. Xint l_ltext=75;
  170. Xint l_rmar1=150;
  171. Xint l_rmar2=175;
  172. Xint l_rtext=200;
  173. X
  174. Xint l_line1=72;
  175. Xint l_line2=60;
  176. Xint l_line3=47;
  177. Xint l_line4=35;
  178. Xint l_line5=22;
  179. Xint l_line6=10;
  180. X
  181. X/* Point sizes for font calls */
  182. Xint titlesize=18;
  183. Xint subtlsize=12;
  184. Xint namesize=10;
  185. Xint lblsize=10;
  186. Xint magsize=8;
  187. X
  188. X/* Fonts for font calls */
  189. Xint namefnt=TIMESROMAN;
  190. Xint lblfnt=TIMESROMAN;
  191. Xint magfnt=COURIER;
  192. Xint titlefnt=TIMESBOLD;
  193. Xint subtlfnt=TIMESROMAN;
  194. X
  195. X/* Scale multiplier, minimum,
  196. X   mangitude change, maximum, for thumbnail,*/
  197. Xdouble th_smul=THSMUL;
  198. Xdouble th_smin=THSMIN;
  199. Xdouble th_madj=THMADJ;
  200. Xdouble th_mmax=THMMAX;
  201. X
  202. X#define MAX(a,b) ((a)>(b)?(a):(b))
  203. X#define MIN(a,b) ((a)<(b)?(a):(b))
  204. X
  205. X/* Font names */
  206. X#ifdef RELEASE3_FONTS
  207. Xstatic char *default_font_name = "*helvetica-medium-r-normal--10*";
  208. Xstatic char *greek_font_name = "*symbol-medium-r-normal--10*";
  209. Xstatic char *timesroman_font_name = "*times-medium-r-normal--";
  210. Xstatic char *timesbold_font_name = "*times-bold-r-normal--";
  211. Xstatic char *timesital_font_name = "*times-roman-i-normal--";
  212. Xstatic char *timesboldital_font_name = "*times-bold-i-normal--";
  213. Xstatic char *helv_font_name = "*helvetica-medium-r-normal--";
  214. Xstatic char *helvbold_font_name = "*helvetica-bold-r-normal--";
  215. Xstatic char *helvital_font_name = "*helvetica-medium-o-normal--";
  216. Xstatic char *helvboldital_font_name = "*helvetica-bold-o-normal--";
  217. Xstatic char *courier_font_name = "*courier-medium-r-normal--";
  218. Xstatic char *courital_font_name = "*courier-medium-i-normal--";
  219. Xstatic char *courbold_font_name = "*courier-bold-r-normal--";
  220. Xstatic char *couritalbold_font_name = "*courier-bold-o-normal--";
  221. X#else
  222. Xstatic char *default_font_name = "helvetica-medium10";
  223. Xstatic char *greek_font_name = "symbol-medium10";
  224. Xstatic char *timesroman_font_name = "times-roman";
  225. Xstatic char *timesbold_font_name = "times-bold";
  226. Xstatic char *timesital_font_name = "times-italic";
  227. Xstatic char *timesboldital_font_name = "times-bold-italic";
  228. Xstatic char *helv_font_name = "helvetica-medium";
  229. Xstatic char *helvbold_font_name = "helvetica-bold";
  230. Xstatic char *helvital_font_name = "helvetica-oblique";
  231. Xstatic char *helvboldital_font_name = "helvetica-boldoblique";
  232. Xstatic char *courier_font_name = "courier-medium";
  233. Xstatic char *courital_font_name = "courier-medium";
  234. Xstatic char *courbold_font_name = "courier-bold";
  235. Xstatic char *couritalbold_font_name = "courier-bold";
  236. X#endif /* RELEASE3_FONTS */
  237. X
  238. X
  239. X
  240. X/* Device control argument */
  241. XD_control_arg(s)
  242. Xchar *s;
  243. X{
  244. X  int i = 0;
  245. X  int c;
  246. X  int j;
  247. X
  248. X  while (c = s[i++])
  249. X    switch (c) {
  250. X    case 'p': /* Postscript preview */
  251. X      post_preview = TRUE;
  252. X      break;
  253. X    case 'l': /* Postscript landscape */
  254. X      post_preview = TRUE;
  255. X      post_landscape = TRUE;
  256. X      break;
  257. X    case 'h': /* Hide */
  258. X      hide_drawing = use_backup = TRUE;
  259. X      break;
  260. X    case 'b': /* Use backup */
  261. X      use_backup = TRUE;
  262. X      break;
  263. X    case 'm': /* monochrome display */
  264. X      is_color = FALSE;
  265. X      break;
  266. X#ifdef STARXAW
  267. X    case 't': /* Toolkit */
  268. X      /* skip current argument */
  269. X      j = i-1;
  270. X      while (s[j]) {
  271. X    if (s[j] == ' ') {
  272. X      s[j] = '\0';
  273. X      if (Xargc < 39)
  274. X        Xargv[Xargc++] = &s[j+1];
  275. X    };
  276. X    j++;
  277. X      };
  278. X      i = j-1;
  279. X      break;
  280. X#endif
  281. X    default:
  282. X      break;
  283. X    }
  284. X}
  285. X
  286. X
  287. X#ifdef STARX11
  288. X/* Open the device */
  289. XD_open()
  290. X{
  291. X  int x, y;
  292. X  unsigned int border, depth, map_width;
  293. X  Pixmap icon;
  294. X  XSizeHints sizehints;
  295. X  double legend_spacing;
  296. X
  297. X  if (!(display = XOpenDisplay(NULL)))
  298. X    return FALSE;
  299. X   
  300. X  X_setdisplay();
  301. X
  302. X  /* open window */
  303. X  window = XCreateSimpleWindow(display, RootWindow(display,screen_num), 12, 12,
  304. X                                 720, 540, 1, foreground, background);
  305. X
  306. X  if (post_preview) {
  307. X    sizehints.flags = PSize|PMinSize|PMaxSize;
  308. X    if (post_landscape) {
  309. X      sizehints.width = sizehints.min_width = sizehints.max_width = 792;
  310. X      sizehints.height = sizehints.min_height = sizehints.max_height = 576;
  311. X    } else {
  312. X      sizehints.width = sizehints.min_width = sizehints.max_width = 576;
  313. X      sizehints.height = sizehints.min_height = sizehints.max_height = 792;
  314. X    };
  315. X  } else {
  316. X    sizehints.flags = PMinSize;
  317. X    sizehints.min_width = 550; sizehints.min_height = 550;
  318. X  }
  319. X
  320. X  icon = XCreateBitmapFromData(display, window, icon_bits, 
  321. X                               icon_width, icon_height);
  322. X  Xargv[0] = g_argv[0];
  323. X  XSetStandardProperties(display, window, prog, prog, icon, Xargv, Xargc,
  324. X                         &sizehints);
  325. X  XDefineCursor(display, window, XCreateFontCursor(display, XC_crosshair));
  326. X  XSelectInput(display, window, StructureNotifyMask);
  327. X  XMapWindow(display, window);
  328. X  while(!XCheckTypedWindowEvent(display, window, MapNotify, &event));
  329. X  XSelectInput(display, window, ExposureMask);
  330. X
  331. X  XGetGeometry(display, window, &root, &x, &y, &width, 
  332. X               &height, &border, &depth);
  333. X  sizehints.max_width = sizehints.min_width = width;
  334. X  sizehints.max_height = sizehints.min_height = height;
  335. X
  336. X
  337. X  map_width = width - 72;
  338. X
  339. X  fullpage.width = map_width;
  340. X  fullpage.height = height - 72;
  341. X  fullpage.x_offset = 18;
  342. X  fullpage.y_offset = 36;
  343. X
  344. X  /* main is 7/10 the printing space 
  345. X   */
  346. X  mainmap.width = map_width;
  347. X  mainmap.height = ((height - 72)*7)/10;
  348. X  mainmap.x_offset = 18;
  349. X  mainmap.y_offset = 18 + ((height - 72)*2.5)/10;
  350. X
  351. X  /* Thumbscale is 2/10 the printing space */
  352. X  thumbmap.width = map_width/2;
  353. X  thumbmap.height = ((height - 72)*2)/10;
  354. X  thumbmap.x_offset = 18 + map_width/2;
  355. X  thumbmap.y_offset = 18;
  356. X
  357. X  /* Need to adjust label here */
  358. X  /* Want top of l_til to be at top of thumbmap */
  359. X  l_til = thumbmap.height + thumbmap.y_offset - titlesize;
  360. X  /* Space text in legends to fill space.  Leave 10 on bottom.
  361. X     Text totals 6*namesize+subtlsize. */
  362. X
  363. X  legend_spacing = (l_til - 10 - 6*namesize - subtlsize)/7;
  364. X  if (legend_spacing < 2) legend_spacing = 2;
  365. X
  366. X  l_stil = l_til - subtlsize - legend_spacing;
  367. X  l_line1 = l_stil - namesize - legend_spacing;
  368. X  l_line2 = l_line1 - namesize - legend_spacing;
  369. X  l_line3 = l_line2 - namesize - legend_spacing;
  370. X  l_line4 = l_line3 - namesize - legend_spacing;
  371. X  l_line5 = l_line4 - namesize - legend_spacing;
  372. X  l_line6 = l_line5 - namesize - legend_spacing;
  373. X
  374. X
  375. X  /* Actually, we left too much space above,
  376. X     for proper postscript simulation.
  377. X     We can make the maps higher */
  378. X  if (!post_preview) {
  379. X    fullpage.height = height - fullpage.y_offset - 18;
  380. X    mainmap.height = height - mainmap.y_offset - 18;
  381. X  }
  382. X
  383. X
  384. X  sizehints.flags = PSize|PMinSize|PMaxSize;
  385. X  XSetNormalHints(display, window, &sizehints);
  386. X
  387. X  if ((!is_color) && use_backup)
  388. X    backup = XCreatePixmap(display, window, width, height, depth);
  389. X  else { /* Can't use backup pixmap on color: not enough memory */
  390. X    use_backup = FALSE;
  391. X    hide_drawing = FALSE;
  392. X  }
  393. X  draw_into = backup ? backup : window;
  394. X/* Should perhaps try and check for failure, and use some other
  395. X   way of selecting use of window vs. backup */
  396. X
  397. X    
  398. X  values_GC.foreground = background; values_GC.background = foreground;
  399. X  XChangeGC(display, default_GC, GCForeground|GCBackground, &values_GC);
  400. X  XFillRectangle(display, draw_into, default_GC, 0, 0, width, height);
  401. X  XSetForeground(display, default_GC, foreground);
  402. X  XSetBackground(display, default_GC, background);
  403. X
  404. X  return TRUE;                /* open successful */
  405. X}
  406. X
  407. X/* Close the device */
  408. XD_close()
  409. X{
  410. X  Window closebox;         /* window to do close in */
  411. X  XEvent closebox_event, window_event;
  412. X  int i;
  413. X  double lat, lon, tlat, tlon;
  414. X  char outstr[81];
  415. X  int ra_h, ra_m, ra_s;
  416. X  int de_d, de_m, de_s;
  417. X  char dsign;
  418. X
  419. X
  420. X  flushlines();
  421. X  if (use_backup)
  422. X    XCopyArea(display, backup, window, default_GC, 0, 0, width, height,
  423. X          0, 0);
  424. X
  425. X  closebox =XCreateSimpleWindow(display,window, 0, 0, 10, 10, 1, background,
  426. X                foreground);
  427. X  XDefineCursor(display, closebox, 
  428. X                XCreateFontCursor(display, XC_top_left_arrow));
  429. X  XMapWindow(display,closebox);
  430. X  XSelectInput(display, closebox, ButtonPressMask);
  431. X  XSelectInput(display, window, ButtonPressMask|ExposureMask);
  432. X
  433. X  D_comment("Waiting for close of window or mouse button 1 or 3 input");
  434. X
  435. X  while (!XCheckWindowEvent(display, closebox, ButtonPressMask,
  436. X                 &closebox_event))
  437. X    {
  438. X      if (XCheckWindowEvent(display, window, ExposureMask, &window_event)
  439. X      && (window_event.type == Expose))
  440. X    if (use_backup)
  441. X      XCopyArea(display, backup, window, default_GC,
  442. X            window_event.xexpose.x, window_event.xexpose.y,
  443. X            window_event.xexpose.width, window_event.xexpose.height,
  444. X            window_event.xexpose.x, window_event.xexpose.y);
  445. X
  446. X      if (XCheckWindowEvent(display, window, ButtonPressMask, &window_event)
  447. X      && (window_event.type == ButtonPress)) {
  448. X    if ((i = invxform((int) window_event.xbutton.x,
  449. X             (int) height - window_event.xbutton.y,
  450. X             &lat, &lon)) >= 0) {
  451. X      if (lon < 0.0) lon += 360.0;
  452. X      tlon = lon / 15.0;
  453. X
  454. X      ra_h = tlon;
  455. X      ra_m = (tlon - ra_h) * 60 + (0.5 / 60);
  456. X      ra_s = (((tlon - ra_h) * 60) - ra_m) * 60 + 0.5;
  457. X
  458. X      if (ra_s >= 60) {ra_s -= 60; ra_m++;};
  459. X      if (ra_m >= 60) {ra_m -= 60; ra_h++;};
  460. X
  461. X
  462. X      if (lat < 0.0) {
  463. X        tlat = -lat;
  464. X        dsign = '-';
  465. X      } else {
  466. X        tlat = lat;
  467. X        dsign = '+';
  468. X      }
  469. X
  470. X      de_d = tlat;
  471. X      de_m = (tlat - de_d) * 60 + (0.5 / 60);
  472. X      de_s = (((tlat - de_d) * 60) - de_m) * 60 + 0.5;
  473. X
  474. X      if (de_s >= 60) {de_s -= 60; de_m++;};
  475. X      if (de_m >= 60) {de_m -= 60; de_d++;};
  476. X
  477. X
  478. X      sprintf(outstr, "RA: %2dh%2dm%2ds   dec: %c%2dd%2dm%2ds",
  479. X          ra_h, ra_m, ra_s, dsign, de_d, de_m, de_s);
  480. X      D_comment(outstr);
  481. X      if (window_event.xbutton.button == Button3)
  482. X        dblookup(i, lat, lon, 10);
  483. X    } else {
  484. X/*      fprintf(stderr, "Returned -1\n");*/
  485. X    }
  486. X      }
  487. X    }
  488. X  
  489. X  XCloseDisplay(display);
  490. X}
  491. X
  492. X#endif /* STARX11 */
  493. X
  494. X#ifndef STARXTK
  495. XX_setdisplay()
  496. X{
  497. X  char *str;
  498. X  char *fore_color, *back_color;
  499. X  XColor cdef;
  500. X  Pixel *planes;
  501. X
  502. X  screen_num = DefaultScreen(display);
  503. X  black = BlackPixel(display, screen_num);
  504. X  white = WhitePixel(display, screen_num);
  505. X
  506. X  if ((str = XGetDefault(display, prog, "ReverseVideo")) 
  507. X     && strcmp(str, "on") == 0)
  508. X     reverse = 1;
  509. X  fore_color = XGetDefault(display, prog, "ForeGround");
  510. X  back_color = XGetDefault(display, prog, "BackGround");
  511. X
  512. X  /* get global defaults from .Xdefaults */
  513. X  get_defaults();
  514. X
  515. X  default_GC = DefaultGC(display, screen_num);
  516. X  default_cmap = DefaultColormap(display, screen_num);
  517. X  default_font = XLoadQueryFont(display, default_font_name);
  518. X
  519. X  greek_font = XLoadQueryFont(display, greek_font_name);
  520. X
  521. X  /* create color map */
  522. X
  523. X  if (reverse) {
  524. X    foreground = black;
  525. X    background = white;
  526. X  }
  527. X  else {
  528. X    foreground = white;
  529. X    background = black;
  530. X  }
  531. X
  532. X  is_color &= (DisplayPlanes(display, screen_num) >= 4);
  533. X  is_super_color = is_color & (DisplayPlanes(display, screen_num) >= 6);
  534. X  ncolors = (is_color ? 12 : 2);
  535. X  star_colors = (is_super_color ? 65: 0);
  536. X
  537. X  if (is_color) {
  538. X    pixels = (Pixel *)
  539. X      malloc((unsigned int) (star_colors+ncolors)*sizeof(Pixel));
  540. X    if (!XAllocColorCells(display, default_cmap, 0, planes,
  541. X              0, pixels, ncolors+star_colors))  {
  542. X      fprintf(stderr, "Error, can't get color cells\n");
  543. X      exit(10);
  544. X    }
  545. X
  546. X    cdef.flags = DoRed|DoBlue|DoGreen;
  547. X    if (!fore_color || 
  548. X        !XParseColor(display, default_cmap, fore_color, &cdef)) {
  549. X      cdef.pixel = foreground ;
  550. X      XQueryColor(display, default_cmap, &cdef) ;
  551. X    }
  552. X    cdef.pixel = pixels[0] ;
  553. X    XStoreColor(display, default_cmap, &cdef) ;
  554. X
  555. X    if (!back_color || 
  556. X        !XParseColor(display, default_cmap, back_color, &cdef)) {
  557. X      cdef.pixel = background ;
  558. X      XQueryColor(display, default_cmap, &cdef) ;
  559. X    }
  560. X    cdef.pixel = pixels[1] ;
  561. X    XStoreColor(display, default_cmap, &cdef) ;
  562. X    D_setcolors();
  563. X  }
  564. X}
  565. X#endif /* not STARXTK */
  566. X
  567. X/* Readstar globals */
  568. Xextern double obj_lat, obj_lon, obj_mag;
  569. Xextern char obj_type[3], obj_color[3], obj_label[3];
  570. Xextern char obj_constell[3], obj_name[];
  571. Xextern char *obj_commnt, fileline[];
  572. X
  573. X/* needed by readstar */
  574. Xint (*readfile)();
  575. Xextern char *cur_file_name;
  576. X
  577. Xdblookup(winnum, lat, lon, dpix)
  578. X     int winnum;
  579. X     double lat, lon;
  580. X     int dpix;
  581. X{
  582. X  int i;
  583. X  double delta;
  584. X  double f_east, f_north, f_west, f_south;
  585. X  FILE *file1, *file2;
  586. X  char ibuf[2020], fname[1030], ftypestr[32];
  587. X  int n;
  588. X  int ftype;
  589. X
  590. X#ifdef STARXAW
  591. X  buffer_comment("Looking for object", FALSE);
  592. X#else
  593. X  D_comment("Looking for object");
  594. X#endif
  595. X
  596. X  delta = mapwin[winnum]->c_scale * dpix;
  597. X
  598. X  for (i = 0; i < mapwin[winnum]->numfiles; i++) {
  599. X    if ((file1 = fopen(mapwin[winnum]->file[i].name, "r")) == NULL) continue;
  600. X
  601. X    cur_file_name = mapwin[winnum]->file[i].name;
  602. X    ftype = mapwin[winnum]->file[i].type;
  603. X    if (mapwin[winnum]->file[i].type == INDEXTYPE) {
  604. X      /* read each line of index file, parse data on the files indexed:
  605. X     region_included file_name
  606. X         use an indexed file if the point is in the region */
  607. X
  608. X      while (!feof(file1)) {
  609. X    fgets(ibuf, 2000, file1);
  610. X    n = sscanf(ibuf, "%lf %lf %lf %lf %1000s %30s\n", &f_east, &f_north,
  611. X           &f_west, &f_south, fname, ftypestr);
  612. X    if ((n != 6) || feof(file1)) continue;
  613. X
  614. X    f_east *= 15.0;
  615. X    f_west *= 15.0;
  616. X
  617. X    if (westof(lon, f_east) && eastof(lon, f_west)
  618. X        && (lat >= f_south) && (lat <= f_north)) {
  619. X      if ((file2 = fopen(fname, "r")) == NULL) {
  620. X        fprintf(stderr, "%s: error, couldn't open '%s' for reading.\n",
  621. X            prog, fname);
  622. X      } else {
  623. X        cur_file_name = fname;
  624. X
  625. X        ftype = tr_fty(ftypestr);
  626. X
  627. X        if (ftype == INDEXTYPE)  {
  628. X          fprintf(stderr,
  629. X  "%s: error, can't use type INDEXTYPE file '%s' from another index file.\n",
  630. X              prog, fname);
  631. X        } else {
  632. X          do_look(file2, ftype, lat, lon, delta);
  633. X        }
  634. X        fclose(file2);
  635. X        cur_file_name = "";
  636. X      }
  637. X    }
  638. X      }
  639. X    } else {
  640. X      do_look(file1, ftype, lat, lon, delta);
  641. X    }
  642. X
  643. X    fclose(file1);
  644. X  };
  645. X
  646. X#ifdef STARXAW
  647. X  buffer_comment("Done search", FALSE);
  648. X#else
  649. X  D_comment("Done search");
  650. X#endif
  651. X}
  652. X
  653. Xdo_look(file, ftype, lat, lon, delta)
  654. XFILE *file;
  655. Xint ftype;
  656. Xdouble lat, lon, delta;
  657. X{
  658. X  double dlat, dlon;
  659. X  double tlat, tlon;
  660. X  int ra_h, ra_m, ra_s;
  661. X  int de_d, de_m, de_s;
  662. X  char dsign;
  663. X
  664. X  char outstr[81];
  665. X
  666. X
  667. X  while (!(*readfile)(file, ftype)) {
  668. X    dlat = fabs(obj_lat - lat);
  669. X    dlon = fabs(obj_lon - lon);
  670. X    if ((dlat <= delta) && (dlon <= delta)) {
  671. X      tlon = obj_lon/15.0;
  672. X      ra_h = tlon;
  673. X      ra_m = (tlon - ra_h) * 60 + (0.5 / 60);
  674. X      ra_s = (((tlon - ra_h) * 60) - ra_m) * 60 + 0.5;
  675. X
  676. X      if (ra_s >= 60) {ra_s -= 60; ra_m++;};
  677. X      if (ra_m >= 60) {ra_m -= 60; ra_h++;};
  678. X
  679. X
  680. X      if (obj_lat < 0.0) {
  681. X    tlat = -obj_lat;
  682. X    dsign = '-';
  683. X      } else {
  684. X    tlat = obj_lat;
  685. X    dsign = '+';
  686. X      }
  687. X
  688. X      de_d = tlat;
  689. X      de_m = (tlat - de_d) * 60 + (0.5 / 60);
  690. X      de_s = (((tlat - de_d) * 60) - de_m) * 60 + 0.5;
  691. X
  692. X      if (de_s >= 60) {de_s -= 60; de_m++;};
  693. X      if (de_m >= 60) {de_m -= 60; de_d++;};
  694. X
  695. X
  696. X
  697. X      sprintf(outstr,
  698. X      "%2dh%2dm%2ds %c%2dd%2dm%2ds %5.2f %2s %2s %2s %3s %-25.25s %-14.14s",
  699. X          ra_h, ra_m, ra_s, dsign, de_d, de_m, de_s, obj_mag,
  700. X          obj_type,  obj_color, obj_label, obj_constell,
  701. X          obj_name, obj_commnt);
  702. X#ifdef STARXAW
  703. X      buffer_comment(outstr, FALSE);
  704. X#else
  705. X      D_comment(outstr);
  706. X#endif
  707. X    }
  708. X  }
  709. X}
  710. X
  711. X
  712. Xstatic int current_x, current_y;
  713. X
  714. X/* Move to (x, y) */
  715. XD_move(x, y)
  716. X     int x, y;
  717. X{
  718. X  current_x = x; current_y = y;
  719. X}
  720. X
  721. X
  722. Xstatic int curr_lsty = -1;
  723. X/* Draw a line of style line_style from the current point to (x, y) */
  724. XD_draw(x, y, line_style)
  725. X     int x, y, line_style;
  726. X{
  727. X  int xline_sty;
  728. X  int dashes = 1;
  729. X
  730. X#ifdef STARXAW
  731. X  if (is_killed()) return; /* Return if process_events returns TRUE,
  732. X                    i.e. if the close box has been hit */
  733. X#endif
  734. X
  735. X  switch (cur_function) {
  736. X  case CHRTOUTLN:
  737. X  case CHRTHTICK:
  738. X  case CHRTVTICK:
  739. X    xline_sty = LineSolid;
  740. X    dashes = 1;
  741. X    break;
  742. X  case GRID_RA:
  743. X  case GRID_DEC:
  744. X    xline_sty = LineDoubleDash;
  745. X    dashes = 4;
  746. X    break;
  747. X  case ECLIPT:
  748. X    xline_sty = LineDoubleDash;
  749. X    dashes = 1;
  750. X    break;
  751. X  case CONSTBOUND:
  752. X    xline_sty = LineDoubleDash;
  753. X    dashes = 6;
  754. X    break;
  755. X  case CONSTPATTRN:
  756. X    xline_sty = LineDoubleDash;
  757. X    dashes = 8;
  758. X    break;
  759. X  case CONSTNAME:
  760. X  case CHARTFILE:
  761. X  default:
  762. X    switch (line_style) {
  763. X    case SOLID:
  764. X    case VECSOLID:
  765. X      xline_sty = LineSolid;
  766. X      dashes = 1;
  767. X      break;
  768. X    case DASHED:
  769. X    case VECDASH:
  770. X      xline_sty = LineDoubleDash;
  771. X      dashes = 5;
  772. X      break;
  773. X    case DOTTED:
  774. X    case VECDOT:
  775. X      xline_sty = LineDoubleDash;
  776. X      dashes = 1;
  777. X      break;
  778. X    default:
  779. X      xline_sty = LineSolid;
  780. X      dashes = 1;
  781. X      break;
  782. X    };
  783. X    break;
  784. X  }
  785. X
  786. X/* Some servers can't do dashes */
  787. X  if (!use_x_dashes)
  788. X    xline_sty = LineSolid;
  789. X
  790. X
  791. X  if (xline_sty != curr_lsty) {
  792. X    values_GC.line_style = xline_sty;
  793. X    values_GC.dashes = dashes;
  794. X    XChangeGC(display, default_GC, GCLineStyle | GCDashList, &values_GC);
  795. X  }
  796. X
  797. X  XDrawLine(display, draw_into, default_GC,
  798. X        current_x, height - current_y, x, height - y);
  799. X
  800. X
  801. X  curr_lsty = xline_sty;
  802. X
  803. X  if ((use_backup) && !hide_drawing)
  804. X    XCopyArea(display, backup, window, default_GC, 0, 0, width, height,
  805. X          0, 0);
  806. X
  807. X/*  XFlush(display);*/
  808. X
  809. X  current_x = x; current_y = y;
  810. X}
  811. X/* This routine is encouraged to look at the extern cur_funtion
  812. X   and change the line style drawn as desired */
  813. X
  814. X
  815. X/* Move to (x1, y1) then draw a line of style line_style to (x2, y2) */
  816. XD_movedraw(x1, y1, x2, y2, line_style)
  817. X     int x1, y1, x2, y2, line_style;
  818. X{
  819. X  D_move(x1, y1);
  820. X  D_draw(x2, y2, line_style);
  821. X}
  822. X
  823. X
  824. Xstatic XPoint areapts[1000];
  825. Xstatic int nareapts;
  826. X/* Move to (x, y) to begin an area */
  827. XD_areamove(x, y)
  828. X     int x, y;
  829. X{
  830. X  nareapts = 0;
  831. X  areapts[nareapts].x = x;
  832. X  areapts[nareapts].y = height - y;
  833. X  nareapts++;
  834. X}
  835. X
  836. X/* Add a segment to the area border */
  837. XD_areaadd(x, y)
  838. X     int x, y;
  839. X{
  840. X  areapts[nareapts].x = x;
  841. X  areapts[nareapts].y = height - y;
  842. X  nareapts++;
  843. X}
  844. X
  845. X/* Fill the area, after adding the last segment */
  846. XD_areafill(x, y)
  847. X     int x, y;
  848. X{
  849. X  areapts[nareapts].x = x;
  850. X  areapts[nareapts].y = height - y;
  851. X  nareapts++;
  852. X
  853. X#ifdef STARXAW
  854. X  if (is_killed()) return; /* Return if process_events returns TRUE,
  855. X                    i.e. if the close box has been hit */
  856. X#endif
  857. X
  858. X  XFillPolygon(display, draw_into, default_GC,
  859. X           areapts, nareapts, Complex, CoordModeOrigin);
  860. X  nareapts = 0;
  861. X}
  862. X
  863. X
  864. X
  865. X
  866. Xstatic int curr_colr;
  867. X/* Set the color to be used for lines, areas and text */
  868. X/* color_str is a 2 char (+ '\0') string
  869. X   containing a specification for a color,
  870. X   e.g. "G2" for the color of a star of spectral class G2, or "r7" for
  871. X   red, level seven.  The interpretation of the color string is left to
  872. X   the device driver */
  873. XD_color(color_str)
  874. X     char *color_str;
  875. X{
  876. X  Pixel colr;
  877. X  int class, subclass;
  878. X  static char *table = "OBAFGKMRNSrgbycpow";
  879. X  static int spectra[10] = {
  880. X    BLUE_WHITE, BLUE, WHITE, WHITE, YELLOW, ORANGE, RED, RED, RED};
  881. X
  882. X  static int super_spectra[][10] = {
  883. X    /*         0   1   2   3   4   5   6   7   8   9   */
  884. X    /* O */ { 32, 32, 32, 32, 32, 32, 32, 32, 32, 32 },
  885. X    /* B */ {  0,  1,  2,  3,  3,  4,  4,  4,  5,  6 },
  886. X    /* A */ {  7,  7,  8,  9,  9, 10, 10, 10, 10, 10 },
  887. X    /* F */ { 11, 11, 12, 12, 12, 13, 13, 13, 14, 14 },
  888. X    /* G */ { 15, 15, 15, 15, 15, 16, 16, 16, 16, 16 },
  889. X    /* K */ { 17, 17, 18, 18, 18, 19, 19, 19, 19, 19 },
  890. X    /* M */ { 20, 20, 21, 22, 23, 24, 25, 26, 26, 26 },
  891. X    /* R */ { 27, 27, 27, 28, 28, 28, 28, 28, 29, 30 },
  892. X    /* N */ { 27, 27, 27, 28, 28, 28, 28, 28, 29, 30 },
  893. X    /* S */ { 30, 30, 30, 30, 31, 31, 31, 31, 31, 31 },
  894. X    /* r */ { 33, 33, 33, 34, 34, 34, 35, 35, 35, 36 },
  895. X    /* g */ { 37, 37, 37, 38, 38, 38, 39, 39, 39, 40 },
  896. X    /* b */ { 41, 41, 41, 42, 42, 42, 43, 43, 43, 44 },
  897. X    /* y */ { 45, 45, 45, 46, 46, 46, 47, 47, 47, 48 },
  898. X    /* c */ { 49, 49, 49, 50, 50, 50, 51, 51, 51, 52 },
  899. X    /* p */ { 53, 53, 53, 54, 54, 54, 55, 55, 55, 56 },
  900. X    /* o */ { 57, 57, 57, 58, 58, 58, 59, 59, 59, 60 },
  901. X    /* w */ { 61, 61, 61, 62, 62, 62, 63, 63, 63, 64 }
  902. X      };
  903. X
  904. X  if (!is_color) return;
  905. X#ifdef STARXAW
  906. X  if (is_killed()) return; /* Return if process_events returns TRUE,
  907. X                    i.e. if the close box has been hit */
  908. X#endif
  909. X
  910. X
  911. X  class = 0;
  912. X  while (table[class] && (table[class] != color_str[0])) class++;
  913. X
  914. X  if (is_super_color) {
  915. X    subclass = isdigit(color_str[1]) ? color_str[1] - '0' : 0;
  916. X    colr = table[class] ? star_pixels[super_spectra[class][subclass]] : 
  917. X      pixels[WHITE];
  918. X  } else
  919. X    colr = table[class] ? pixels[spectra[class]] : pixels[WHITE];
  920. X
  921. X  if (colr != curr_colr) {
  922. X    flushlines();
  923. X    XSetForeground(display, default_GC, colr);
  924. X  };
  925. X}
  926. X
  927. X
  928. Xstatic int current_font = -1, current_fsize = -1;
  929. Xstatic XFontStruct *curr_xfont;
  930. X
  931. X/* Set the font and font size to be used for text. */
  932. X/* Note order of args */
  933. XD_fontsize(fsize, font)
  934. X     int font, fsize;
  935. X{
  936. X  char *fontname, readname[50];
  937. X
  938. X#ifdef STARXAW
  939. X  if (is_killed()) return; /* Return if process_events returns TRUE,
  940. X                    i.e. if the close box has been hit */
  941. X#endif
  942. X
  943. X  switch(cur_function) {
  944. X  case CHRTOUTLN:
  945. X    break;
  946. X  case CHRTHTICK:
  947. X  case CHRTVTICK:
  948. X    font = TIMESBOLD;
  949. X    break;
  950. X  case GRID_RA:
  951. X  case GRID_DEC:
  952. X  case ECLIPT:
  953. X    break;
  954. X  case CONSTBOUND:
  955. X  case CONSTPATTRN:
  956. X    break;
  957. X  case CONSTNAME:
  958. X    font = HELVITAL;
  959. X    break;
  960. X  case CHARTFILE:
  961. X  case CURNTFONT:
  962. X  default:
  963. X    break;
  964. X  }
  965. X
  966. X  if ((font == current_font) && (fsize == current_fsize)) return;
  967. X
  968. X  switch(font)
  969. X    {
  970. X    case TIMESROMAN: fontname = timesroman_font_name; break;
  971. X    case TIMESBOLD: fontname = timesbold_font_name; break;
  972. X    case TIMESITAL: fontname = timesital_font_name; break;
  973. X    case TIMESBOLDITAL: fontname = timesboldital_font_name; break;
  974. X    case HELV: fontname = helv_font_name; break;
  975. X    case HELVBOLD: fontname = helvbold_font_name; break;
  976. X    case HELVITAL: fontname = helvital_font_name; break;
  977. X    case HELVBOLDITAL: fontname = helvboldital_font_name; break;
  978. X    case COURIER: fontname = courier_font_name; break;
  979. X    case COURITAL: fontname = courital_font_name; break;
  980. X    case COURBOLD: fontname = courbold_font_name; break;
  981. X    case COURITALBOLD: fontname = couritalbold_font_name; break;
  982. X    }
  983. X
  984. X#ifdef RELEASE3_FONTS
  985. X  sprintf(readname,"%s%d*",fontname,fsize);
  986. X#else
  987. X  sprintf(readname,"%s%d",fontname,fsize);
  988. X#endif
  989. X
  990. X  if (!(curr_xfont = XLoadQueryFont(display, readname)))
  991. X    curr_xfont = default_font;
  992. X  else {
  993. X    current_font = font;
  994. X    current_fsize = fsize;
  995. X  }
  996. X
  997. X  if (curr_xfont)
  998. X    XSetFont(display, default_GC, curr_xfont->fid);
  999. X}
  1000. X/* This routine is encouraged to look at the extern cur_funtion
  1001. X   and change the font used as desired */
  1002. X
  1003. X
  1004. Xstatic char  *intable = " 0123456789abgdezh@iklmnEoprstuOx%w";
  1005. Xstatic char *outtable = " 0123456789abgdezhqiklmnxoprstujcyw";
  1006. X/* Display text string str at x,y, in current font and font size.
  1007. X   if star_lbl is TRUE, string is a star label, use
  1008. X      greek characters (if possible) */
  1009. XD_text(x, y, s, star_lbl)
  1010. X     int x, y;
  1011. X     char *s;
  1012. X     int star_lbl;
  1013. X{
  1014. X  char ch;
  1015. X  int i, j;
  1016. X  int use_greek = FALSE;
  1017. X
  1018. X#ifdef STARXAW
  1019. X  if (is_killed()) return; /* Return if process_events returns TRUE,
  1020. X                    i.e. if the close box has been hit */
  1021. X#endif
  1022. X
  1023. X  if (star_lbl) {
  1024. X    if (isgreek(s[0]) && (isdigit(s[1]) || (s[1] == ' '))) {
  1025. X      /* Greek if first character is greek encoded,
  1026. X     and the second is space or a digit */
  1027. X      use_greek = TRUE;
  1028. X      if (greek_font)
  1029. X    XSetFont(display, default_GC, greek_font->fid);
  1030. X#ifdef OLD_GREEK
  1031. X      /* Translate yaleformat greek encoding to Symbol font encoding */
  1032. X      i = 0;
  1033. X      while (ch = s[i])
  1034. X    {
  1035. X      j = 0;
  1036. X      while (intable[j] && (intable[j] != ch)) j++;
  1037. X      s[i] = intable[j] ? outtable[j] : s[i];
  1038. X      /* If not in translation table, leave it alone */
  1039. X      i++;
  1040. X    }
  1041. X#endif
  1042. X    } else { /* Star label, but not greek */
  1043. X    /* remove leading spaces */
  1044. X    while (*s == ' ') s++;
  1045. X    }
  1046. X  }
  1047. X
  1048. X  XDrawString(display, draw_into, default_GC, x,
  1049. X          height - y, s, strlen(s));
  1050. X
  1051. X  if ((use_backup) && !hide_drawing)
  1052. X    XCopyArea(display, backup, window, default_GC, 0, 0, width, height,
  1053. X          0, 0);
  1054. X
  1055. X/*  XFlush(display);*/
  1056. X
  1057. X  if (use_greek && curr_xfont) XSetFont(display, default_GC, curr_xfont->fid);
  1058. X}
  1059. X
  1060. Xisgreek(c)
  1061. Xchar c;
  1062. X{
  1063. X  char *cp;
  1064. X
  1065. X#ifdef OLD_GREEK
  1066. X  cp = "abgdezh@iklmnEoprstuOx%w";
  1067. X#else
  1068. X  cp = "abgdezhqiklmnxoprstujcyw";
  1069. X#endif
  1070. X  while (*cp && (*cp != c)) cp++;
  1071. X  return (*cp != '\0'); /* True if letter was in greek string */
  1072. X}
  1073. X
  1074. X
  1075. X/* Return input coordinate in device coords where there are pointing devices */
  1076. XD_inxy(x, y)
  1077. X     int *x, *y;
  1078. X{
  1079. X}
  1080. X
  1081. X
  1082. X/* Put non-displayed comment in output.  Allowed in postscript, but
  1083. X   few other drivers will be able to support this. */ 
  1084. X#ifdef STARX11
  1085. XD_comment(str)
  1086. X     char *str;
  1087. X{
  1088. X  fprintf(stderr, "%s\n", str);
  1089. X}
  1090. X#endif /* STARX11 */
  1091. X
  1092. X
  1093. X
  1094. X/**
  1095. XHigher level functions
  1096. X**/
  1097. X
  1098. Xdrawlen(x, y, dx, dy, len)
  1099. X     int x,y, dx, dy, len;
  1100. X{
  1101. X  buildlines(x + dx, (int)(height - (y+dy)), x+dx+len, (int)(height - (y+dy)));
  1102. X}
  1103. X
  1104. X
  1105. XD_setcolors()
  1106. X{
  1107. X  Cardinal i;
  1108. X
  1109. X  static int data[][3] = {
  1110. X    {   0,   0,   0 },   /* BLACK */
  1111. X    { 255, 255, 255 },   /* WHITE */
  1112. X    { 255,   0,   0 },   /* RED */
  1113. X    { 255, 100,   0 },   /* ORANGE */
  1114. X    { 255, 255,   0 },   /* YELLOW */
  1115. X    {   0, 255,   0 },   /* GREEN */
  1116. X    {   0, 255, 255 },   /* CYAN */
  1117. X    {   0,   0, 255 },   /* BLUE */
  1118. X    { 255,   0, 255 },   /* VIOLET */
  1119. X    { 130, 130, 255 },   /* BLUE_WHITE */
  1120. X  };
  1121. X
  1122. X  double max_colr;
  1123. X
  1124. X  static double super_data[][3] = {
  1125. X    /*  Red             Green           Blue    Name by which type is known */
  1126. X/*  0 */    { 0.38937,        0.46526,        0.79493 },    /* B0 */
  1127. X/*  1 */    { 0.39501,        0.47146,        0.78847 },    /* B1 */
  1128. X/*  2 */    { 0.40103,        0.47792,        0.78151 },    /* B2 */
  1129. X/*  3 */    { 0.40640,        0.48355,        0.77526 },    /* B3 */
  1130. X/*  4 */    { 0.41341,        0.49071,        0.76701 },    /* B5 */
  1131. X/*  5 */    { 0.43251,        0.50914,        0.74412 },    /* B8 */
  1132. X/*  6 */    { 0.44342,        0.51897,        0.73079 },    /* B9 */
  1133. X/*  7 */    { 0.45181,        0.52618,        0.72042 },    /* A0 */
  1134. X/*  8 */    { 0.46931,        0.54026,        0.69847 },    /* A2 */
  1135. X/*  9 */    { 0.47958,        0.54792,        0.68541 },    /* A3 */
  1136. X/* 10 */    { 0.48538,        0.55205,        0.67797 },    /* A5 */
  1137. X/* 11 */    { 0.50879,        0.56731,        0.64752 },    /* F0 */
  1138. X/* 12 */    { 0.51732,        0.57231,        0.63627 },    /* F2 */
  1139. X/* 13 */    { 0.52348,        0.57573,        0.62810 },    /* F5 */
  1140. X/* 14 */    { 0.54076,        0.58447,        0.60496 },    /* F8 */
  1141. X/* 15 */    { 0.54853,        0.58799,        0.59446 },    /* G0 */
  1142. X/* 16 */    { 0.56951,        0.59623,        0.56584 },    /* G5 */
  1143. X/* 17 */    { 0.58992,        0.60244,        0.53765 },    /* K0 */
  1144. X/* 18 */    { 0.61098,        0.60693,        0.50828 },    /* K2 */
  1145. X/* 19 */    { 0.63856,        0.60977,        0.46950 },    /* K5 */
  1146. X/* 20 */    { 0.68698,        0.60595,        0.40110 },    /* M0 */
  1147. X/* 21 */    { 0.72528,        0.59434,        0.34744 },    /* M2 */
  1148. X/* 22 */    { 0.75182,        0.58144,        0.31097 },    /* M3 */
  1149. X/* 23 */    { 0.78033,        0.56272,        0.27282 },    /* M4 */
  1150. X/* 24 */    { 0.81066,        0.53676,        0.23394 },    /* M5 */
  1151. X/* 25 */    { 0.84247,        0.50195,        0.19570 },    /* M6 */
  1152. X/* 26 */    { 0.87512,        0.45667,        0.16004 },    /* M7 */
  1153. X/* 27 */    { 0.71033,        0.59983,        0.36829 },    /* N0 */
  1154. X/* 28 */    { 0.78625,        0.55816,        0.26507 },    /* N3 */
  1155. X/* 29 */    { 0.93792,        0.33011,        0.10649 },    /* N8 */
  1156. X/* 30 */    { 0.94897,        0.29906,        0.10012 },    /* N9 */
  1157. X/* 31 */    { 0.79832,        0.54811,        0.24950 },    /* S4 */
  1158. X/* 32 */    { 0.38241,        0.45743,        0.80282 },    /* O  */
  1159. X  };
  1160. X
  1161. X  XColor c;
  1162. X
  1163. X  static struct {unsigned char red, green, blue;} other_colrs[] = {
  1164. X    { 0x80, 0, 0},
  1165. X    { 0xc0, 0, 0},
  1166. X    { 0xe0, 0, 0},
  1167. X    { 0xff, 0, 0},
  1168. X    { 0x0, 0x80, 0},
  1169. X    { 0x0, 0xc0, 0},
  1170. X    { 0x0, 0xe0, 0},
  1171. X    { 0x0, 0xff, 0},
  1172. X    { 0x0, 0x0, 0x80},
  1173. X    { 0x0, 0x0, 0xc0},
  1174. X    { 0x0, 0x0, 0xe0},
  1175. X    { 0x0, 0x0, 0xff},
  1176. X    { 0x80, 0x80, 0x0},
  1177. X    { 0xc0, 0xc0, 0x0},
  1178. X    { 0xe0, 0xe0, 0x0},
  1179. X    { 0xff, 0xff, 0x0},
  1180. X    { 0x0, 0x80, 0x80},
  1181. X    { 0x0, 0xc0, 0xc0},
  1182. X    { 0x0, 0xe0, 0xe0},
  1183. X    { 0x0, 0xff, 0xff},
  1184. X    { 0x80, 0x0, 0x80},
  1185. X    { 0xc0, 0x0, 0xc0},
  1186. X    { 0xe0, 0x0, 0xe0},
  1187. X    { 0xff, 0x0, 0xff},
  1188. X    { 0x80, 0x40, 0x00},
  1189. X    { 0xc0, 0x60, 0x00},
  1190. X    { 0xe0, 0x70, 0x00},
  1191. X    { 0xff, 0x80, 0x00},
  1192. X    { 0x80, 0x80, 0x80},
  1193. X    { 0xc0, 0xc0, 0xc0},
  1194. X    { 0xe0, 0xe0, 0xe0},
  1195. X    { 0xff, 0xff, 0xff}
  1196. X  };
  1197. X
  1198. X
  1199. X  c.flags = DoRed|DoGreen|DoBlue;
  1200. X  for (i=0; i<=9; i++) {
  1201. X    c.red = 256*data[i][0];
  1202. X    c.green = 256*data[i][1];
  1203. X    c.blue = 256*data[i][2];
  1204. X    c.pixel = pixels[i];
  1205. X    XStoreColor(display, default_cmap, &c);
  1206. X  }
  1207. X  
  1208. X  if (is_super_color) {
  1209. X    star_pixels = &(pixels[i]);
  1210. X    for (i=0; i<=32; i++) {
  1211. X      max_colr = super_data[i][0];
  1212. X      max_colr = super_data[i][1] > max_colr ? super_data[i][1] : max_colr;
  1213. X      max_colr = super_data[i][2] > max_colr ? super_data[i][2] : max_colr;
  1214. X      c.red = (int) 256*255*super_data[i][0] / max_colr;
  1215. X      c.green = (int) 256*255*super_data[i][1] /max_colr;
  1216. X      c.blue = (int) 256*255*super_data[i][2] /max_colr;
  1217. X      c.pixel = star_pixels[i];
  1218. X      XStoreColor(display, default_cmap, &c);
  1219. X    }
  1220. X    for (i = 33; i <= 64; i++) {
  1221. X      c.red = other_colrs[i-33].red*256;
  1222. X      c.green = other_colrs[i-33].green*256;
  1223. X      c.blue = other_colrs[i-33].blue*256;
  1224. X      c.pixel = star_pixels[i];
  1225. X      XStoreColor(display, default_cmap, &c);
  1226. X    };
  1227. X  }
  1228. X}
  1229. X
  1230. X
  1231. X#ifndef STARXTK
  1232. X/* Differ in starXtk */
  1233. X#define MAXDRAW 250
  1234. Xstatic XSegment seg[MAXDRAW];
  1235. Xstatic int npoints = 0;
  1236. X
  1237. Xbuildlines(x1, y1, x2, y2)
  1238. X     int x1, y1, x2, y2;
  1239. X{
  1240. X#ifdef STARXAW
  1241. X  if (is_killed()) return; /* Return if process_events returns TRUE,
  1242. X                    i.e. if the close box has been hit */
  1243. X#endif
  1244. X
  1245. X  if (npoints == MAXDRAW) flushlines();
  1246. X  seg[npoints].x1 = x1;
  1247. X  seg[npoints].y1 = y1;
  1248. X  seg[npoints].x2 = x2;
  1249. X  seg[npoints].y2 = y2;
  1250. X  npoints++;
  1251. X}
  1252. X
  1253. Xflushlines()
  1254. X{
  1255. X#ifdef STARXAW
  1256. X  if (is_killed()) {
  1257. X    npoints = 0;
  1258. X    return; /* Return if process_events returns TRUE,
  1259. X           i.e. if the close box has been hit */
  1260. X  };
  1261. X#endif
  1262. X
  1263. X  curr_lsty = values_GC.line_style = LineSolid;
  1264. X  values_GC.dashes = 1;
  1265. X  XChangeGC(display, default_GC, GCLineStyle | GCDashList, &values_GC);
  1266. X
  1267. X  XDrawSegments(display, draw_into, default_GC, seg, npoints);
  1268. X  npoints = 0;
  1269. X
  1270. X  if ((use_backup) && !hide_drawing)
  1271. X    XCopyArea(display, backup, window, default_GC, 0, 0, width, height,
  1272. X          0, 0);
  1273. X  XFlush(display);
  1274. X}
  1275. X
  1276. Xkilllines()
  1277. X{
  1278. X  npoints = 0;
  1279. X}
  1280. X#endif /* not STARXtk */
  1281. X
  1282. X
  1283. X/* get global defaults from .Xdefaults */
  1284. Xget_defaults()
  1285. X{
  1286. X  char *str;
  1287. X  int i;
  1288. X
  1289. X  /* Allow fonts to be overriden */
  1290. X  if (str = XGetDefault(display, prog,"default_font_name"))
  1291. X    default_font_name = str;
  1292. X  if (str =  XGetDefault(display, prog, "greek_font_name"))
  1293. X    greek_font_name = str;
  1294. X  if (str =  XGetDefault(display, prog, "timesroman_font_name"))
  1295. X    timesroman_font_name = str;
  1296. X  if (str =  XGetDefault(display, prog, "timesbold_font_name"))
  1297. X    timesbold_font_name = str;
  1298. X  if (str =  XGetDefault(display, prog, "timesital_font_name"))
  1299. X    timesital_font_name = str;
  1300. X  if (str =  XGetDefault(display, prog, "timesboldital_font_name"))
  1301. X    timesboldital_font_name = str;
  1302. X  if (str =  XGetDefault(display, prog, "helv_font_name"))
  1303. X    helv_font_name = str;
  1304. X  if (str =  XGetDefault(display, prog, "helvbold_font_name"))
  1305. X    helvbold_font_name = str;
  1306. X  if (str =  XGetDefault(display, prog, "helvital_font_name"))
  1307. X    helvital_font_name = str;
  1308. X  if (str =  XGetDefault(display, prog, "helvboldital_font_name"))
  1309. X    helvboldital_font_name = str;
  1310. X  if (str =  XGetDefault(display, prog, "courier_font_name"))
  1311. X    courier_font_name = str;
  1312. X  if (str =  XGetDefault(display, prog, "courital_font_name"))
  1313. X    courital_font_name = str;
  1314. X  if (str =  XGetDefault(display, prog, "courbold_font_name"))
  1315. X    courbold_font_name = str;
  1316. X  if (str =  XGetDefault(display, prog, "couritalbold_font_name"))
  1317. X    couritalbold_font_name = str;
  1318. X
  1319. X  /* set post_preview, hide_drawing, use_backup from .Xdefaults */
  1320. X  if ((str = XGetDefault(display, prog, "PostscriptPreview"))
  1321. X     && (!strcmp(str, "on") || !strcmp(str, "true")))
  1322. X    post_preview = TRUE;
  1323. X  if ((str = XGetDefault(display, prog, "PostscriptLandscape"))
  1324. X     && (!strcmp(str, "on") || !strcmp(str, "true")))
  1325. X    post_landscape = TRUE;
  1326. X  if ((str = XGetDefault(display, prog, "HideDrawing"))
  1327. X     && (!strcmp(str, "on") || !strcmp(str, "true")))
  1328. X    hide_drawing = TRUE;
  1329. X  if ((str = XGetDefault(display, prog, "UseBackup"))
  1330. X     && (!strcmp(str, "on") || !strcmp(str, "true")))
  1331. X    use_backup = TRUE;
  1332. X
  1333. X  if ((str = XGetDefault(display, prog, "UseXDashes"))
  1334. X     && (!strcmp(str, "on") || !strcmp(str, "true")))
  1335. X     use_x_dashes = TRUE;
  1336. X
  1337. X  if (str = XGetDefault(display, prog, "htick_lim"))
  1338. X    htick_lim = atoi(str);
  1339. X  if (str = XGetDefault(display, prog, "htext_lim"))
  1340. X    htext_lim = atoi(str);
  1341. X  if (str = XGetDefault(display, prog, "htext_xoff"))
  1342. X    htext_xoff = atoi(str);
  1343. X  if (str = XGetDefault(display, prog, "htext_yoff"))
  1344. X    htext_yoff = atoi(str);
  1345. X  if (str = XGetDefault(display, prog, "vtick_lim"))
  1346. X    vtick_lim = atoi(str);
  1347. X  if (str = XGetDefault(display, prog, "vtext_lim"))
  1348. X    vtext_lim = atoi(str);
  1349. X  if (str = XGetDefault(display, prog, "vtext_xoff"))
  1350. X    vtext_xoff = atoi(str);
  1351. X  if (str = XGetDefault(display, prog, "vtext_yoff"))
  1352. X    vtext_yoff = atoi(str);
  1353. X
  1354. X
  1355. X/* externs for labels */
  1356. X  if (str = XGetDefault(display, prog, "x_nameoffset"))
  1357. X    x_nameoffset = atoi(str);
  1358. X  if (str = XGetDefault(display, prog, "y_nameoffset"))
  1359. X    y_nameoffset = atoi(str);
  1360. X  if (str = XGetDefault(display, prog, "x_lbloffset"))
  1361. X    x_lbloffset = atoi(str);
  1362. X  if (str = XGetDefault(display, prog, "y_lbloffset"))
  1363. X    y_lbloffset = atoi(str);
  1364. X  if (str = XGetDefault(display, prog, "x_magoffset"))
  1365. X    x_magoffset = atoi(str);
  1366. X  if (str = XGetDefault(display, prog, "y_magoffset"))
  1367. X    y_magoffset = atoi(str);
  1368. X
  1369. X/* externs for legend: variables of positioning are here */
  1370. X  if (str = XGetDefault(display, prog, "l_til"))
  1371. X    l_til = atoi(str);
  1372. X  if (str = XGetDefault(display, prog, "l_stil"))
  1373. X    l_stil = atoi(str);
  1374. X
  1375. X  if (str = XGetDefault(display, prog, "l_lmar1"))
  1376. X    l_lmar1 = atoi(str);
  1377. X  if (str = XGetDefault(display, prog, "l_lmar2"))
  1378. X    l_lmar2 = atoi(str);
  1379. X  if (str = XGetDefault(display, prog, "l_ltext"))
  1380. X    l_ltext = atoi(str);
  1381. X  if (str = XGetDefault(display, prog, "l_rmar1"))
  1382. X    l_rmar1 = atoi(str);
  1383. X  if (str = XGetDefault(display, prog, "l_rmar2"))
  1384. X    l_rmar2 = atoi(str);
  1385. X  if (str = XGetDefault(display, prog, "l_rtext"))
  1386. X    l_rtext = atoi(str);
  1387. X
  1388. X  if (str = XGetDefault(display, prog, "l_line1"))
  1389. X    l_line1 = atoi(str);
  1390. X  if (str = XGetDefault(display, prog, "l_line2"))
  1391. X    l_line2 = atoi(str);
  1392. X  if (str = XGetDefault(display, prog, "l_line3"))
  1393. X    l_line3 = atoi(str);
  1394. X  if (str = XGetDefault(display, prog, "l_line4"))
  1395. X    l_line4 = atoi(str);
  1396. X  if (str = XGetDefault(display, prog, "l_line5"))
  1397. X    l_line5 = atoi(str);
  1398. X  if (str = XGetDefault(display, prog, "l_line6"))
  1399. X    l_line6 = atoi(str);
  1400. X
  1401. X/* Point sizes for font calls */
  1402. X  if (str = XGetDefault(display, prog, "titlesize"))
  1403. X    titlesize = atoi(str);
  1404. X  if (str = XGetDefault(display, prog, "subtlsize"))
  1405. X    subtlsize = atoi(str);
  1406. X  if (str = XGetDefault(display, prog, "namesize"))
  1407. X    namesize = atoi(str);
  1408. X  if (str = XGetDefault(display, prog, "lblsize"))
  1409. X    lblsize = atoi(str);
  1410. X  if (str = XGetDefault(display, prog, "magsize"))
  1411. X    magsize = atoi(str);
  1412. X
  1413. X/* Fonts for font calls */
  1414. X  if ((str = XGetDefault(display, prog, "namefnt")) && (i = tr_fname(str)))
  1415. X    namefnt = i;
  1416. X  if ((str = XGetDefault(display, prog, "lblfnt")) && (i = tr_fname(str)))
  1417. X    lblfnt = i;
  1418. X  if ((str = XGetDefault(display, prog, "magfnt")) && (i = tr_fname(str)))
  1419. X    magfnt = i;
  1420. X  if ((str = XGetDefault(display, prog, "titlefnt")) && (i = tr_fname(str)))
  1421. X    titlefnt = i;
  1422. X  if ((str = XGetDefault(display, prog, "subtlfnt")) && (i = tr_fname(str)))
  1423. X    subtlfnt = i;
  1424. X
  1425. X/* Scale multiplier, minimum,
  1426. X   mangitude change, maximum, for thumbnail,*/
  1427. X  if (str = XGetDefault(display, prog, "th_smul"))
  1428. X    th_smul = atoi(str);
  1429. X  if (str = XGetDefault(display, prog, "th_smin"))
  1430. X    th_smin = atoi(str);
  1431. X  if (str = XGetDefault(display, prog, "th_madj"))
  1432. X    th_madj = atoi(str);
  1433. X  if (str = XGetDefault(display, prog, "th_mmax"))
  1434. X    th_mmax = atoi(str);
  1435. X}
  1436. X
  1437. X
  1438. X
  1439. Xint tr_fname(s)
  1440. Xchar *s;
  1441. X{
  1442. X  int i;
  1443. X
  1444. X  for (i = 0; s[i]; i++)
  1445. X    if (isupper(s[i]))
  1446. X      s[i] = tolower(s[i]);
  1447. X
  1448. X  if(!strcmp(s, "timesroman")) return TIMESROMAN;
  1449. X  else if (!strcmp(s, "timesbold")) return TIMESBOLD;
  1450. X  else if (!strcmp(s, "timesital")) return TIMESITAL;
  1451. X  else if (!strcmp(s, "timesboldital")) return TIMESBOLDITAL;
  1452. X  else if (!strcmp(s, "helv")) return HELV;
  1453. X  else if (!strcmp(s, "helvbold")) return HELVBOLD;
  1454. X  else if (!strcmp(s, "helvital")) return HELVITAL;
  1455. X  else if (!strcmp(s, "helvboldital")) return HELVBOLDITAL;
  1456. X  else if (!strcmp(s, "courier")) return COURIER;
  1457. X  else if (!strcmp(s, "courbold")) return COURBOLD;
  1458. X  else if (!strcmp(s, "courital")) return COURITAL;
  1459. X  else if (!strcmp(s, "couritalbold")) return COURITALBOLD;
  1460. X  else return 0;
  1461. X}
  1462. END_OF_FILE
  1463. if test 40722 -ne `wc -c <'starchart/starX11.c'`; then
  1464.     echo shar: \"'starchart/starX11.c'\" unpacked with wrong size!
  1465. fi
  1466. # end of 'starchart/starX11.c'
  1467. fi
  1468. echo shar: End of archive 29 \(of 32\).
  1469. cp /dev/null ark29isdone
  1470. MISSING=""
  1471. 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
  1472.     if test ! -f ark${I}isdone ; then
  1473.     MISSING="${MISSING} ${I}"
  1474.     fi
  1475. done
  1476. if test "${MISSING}" = "" ; then
  1477.     echo You have unpacked all 32 archives.
  1478.     rm -f ark[1-9]isdone ark[1-9][0-9]isdone
  1479. else
  1480.     echo You still need to unpack the following archives:
  1481.     echo "        " ${MISSING}
  1482. fi
  1483. ##  End of shell archive.
  1484. exit 0
  1485.  
  1486.  
  1487.