home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1994 March / Source_Code_CD-ROM_Walnut_Creek_March_1994.iso / compsrcs / misc / volume34 / starhp / part02 < prev    next >
Encoding:
Text File  |  1992-12-07  |  37.1 KB  |  1,201 lines

  1. Newsgroups: comp.sources.misc
  2. From: kirk@sdd.hp.com (Kirk Norton)
  3. Subject:  v34i019:  starhp - HP-GL/2 StarChart driver, Part02/02
  4. Message-ID: <1992Dec8.014548.28558@sparky.imd.sterling.com>
  5. X-Md4-Signature: a4d9db02f5d13b4e9a65ebdc0f353f88
  6. Date: Tue, 8 Dec 1992 01:45:48 GMT
  7. Approved: kent@sparky.imd.sterling.com
  8.  
  9. Submitted-by: kirk@sdd.hp.com (Kirk Norton)
  10. Posting-number: Volume 34, Issue 19
  11. Archive-name: starhp/part02
  12. Environment: HP-GL/2, Starchart
  13.  
  14. #! /bin/sh
  15. # This is a shell archive.  Remove anything before this line, then feed it
  16. # into a shell via "sh file" or similar.  To overwrite existing files,
  17. # type "sh file -c".
  18. # Contents:  starhp.1 starhp.c.A
  19. # Wrapped by kent@sparky on Mon Dec  7 19:27:02 1992
  20. PATH=/bin:/usr/bin:/usr/ucb:/usr/local/bin:/usr/lbin ; export PATH
  21. echo If this archive is complete, you will see the following message:
  22. echo '          "shar: End of archive 2 (of 2)."'
  23. if test -f 'starhp.1' -a "${1}" != "-c" ; then 
  24.   echo shar: Will not clobber existing file \"'starhp.1'\"
  25. else
  26.   echo shar: Extracting \"'starhp.1'\" \(3527 characters\)
  27.   sed "s/^X//" >'starhp.1' <<'END_OF_FILE'
  28. X.TH STARCHART LOCAL "15 July 1989"
  29. X.ad b
  30. X.SH NAME
  31. Xstarhp \- create astronomical star charts.
  32. X.SH SYNOPSIS
  33. XArguments as in other starchart programs, with the special argument -a:
  34. X.br
  35. X.B \-a
  36. X"\fBm\fR
  37. X[
  38. X.I mag-1
  39. X:
  40. X.I mag0
  41. X:
  42. X.I mag1
  43. X:
  44. X.I mag2
  45. X:
  46. X.I ...
  47. X]
  48. X|
  49. X.B \-a
  50. X\fBs\fR
  51. X[
  52. X.I D0
  53. X[
  54. X.I v0
  55. X[
  56. X.I k
  57. X]]]
  58. X|
  59. X\fBn\fR
  60. X[
  61. X.I rad1
  62. X:
  63. X.I rad2
  64. X:
  65. X.I rad3
  66. X:
  67. X.I rad4
  68. X:
  69. X.I ...
  70. X]
  71. X|
  72. X.BI f " file"
  73. X|
  74. X.B c
  75. X|
  76. X\fBl\fR
  77. X|
  78. X\fBA\fR
  79. X|
  80. X\fBB\fR
  81. X|
  82. X\fBC\fR
  83. X|
  84. X\fBD\fR
  85. X|
  86. X\fBE\fR"
  87. X.br
  88. X
  89. X.SH DESCRIPTION
  90. XSee starchart(1) for details on the starchart programs in general.
  91. X.PP
  92. XSee starpost(1) for details on other supported control options.
  93. X.PP
  94. XAll arguments described for the starpost driver are supported identically in 
  95. Xstarhp, including color support.  Additionally, starhp 
  96. Xwill accept options to specify the desired plot size.  The options \fBA\fR, 
  97. X\fBB\fR, \fBC\fR, \fBD\fR, and \fBE\fR will cause starhp to create either an 
  98. XA, B, C, D, or E size plot file respectively.  These options enable the user 
  99. Xto create star charts of any size, up to the maximum plot size of the device 
  100. X(usually 8.5x11 inches for an A size printer, and 34x44 inches for an E size 
  101. Xplotter). If the target device is a laser printer, no size specification 
  102. Xshould be used, since it will result in an incorrectly scaled and rotated plot.
  103. X.PP
  104. XThe output of this program is HP-GL/2:  a printer and plotter
  105. Xvector graphics language.  Any HP or compatible printer/plotter should work
  106. Xwith this program provided the device supports HP-GL/2.  Older devices,
  107. Xsuch as HP DeskJet, PaintJet, and LaserJets before the IIP are not 
  108. Xcompatible and should not be used, since they are PCL-only (raster-only)
  109. Xdevices and will produce many pages of text garbage.  To generate starcharts
  110. Xon these devices, the starlaser driver should be used instead.
  111. X.PP
  112. XThe older HP-GL (not HP-GL/2) plotters may have some problems with the
  113. Xcharts generated by this driver, since HP-GL varies from device to device.
  114. XFor example, the origin of the plot may be shifted so that only one fourth
  115. Xof the plot appears, the scaling may be incorrect on some devices, and
  116. Xothers may have trouble with text, etc.  Time permitting, future versions of 
  117. Xthis driver may attempt to support HP-GL in addition to HP-GL/2.
  118. X.PP
  119. XOutput quality is dependent on the printing device used.  For example,
  120. Xlaser printers should generate Postscript-quality output, while large format 
  121. Xplotters will probably not support many of the nicer-looking fonts.
  122. X
  123. X.SH EXAMPLE
  124. Xstarhp -r 17.45 -d -29 -t "Galactic Center" -s 10 -m 9 -l 6 
  125. X.br
  126. X(for HP-GL/2 LaserJets)
  127. X.sp1
  128. Xstarhp -a D -a l -a "f orion.HPGL2" -s 45 -b -c ori -g 5
  129. X.br
  130. X(for D or E-size plotters)
  131. X.SH BUGS
  132. XBecause pen plotters are incapable of erasing previously drawn objects,
  133. Xstar haloing will not work on these plotters.  
  134. XNotebook mode will also be
  135. Xaffected by this limitation, since the thumbnail map cannot be erased before
  136. Xthe note prompts are printed.
  137. X.PP
  138. XSome devices may not have enough internal memory to render high density
  139. Xstar charts, and may eject the page when it is only partially printed.
  140. XIn these instances, it will be necessary to reduce the number of objects
  141. Xappearing on the page before it will be printed completely (i.e. reduce
  142. Xthe magnitude limit or the scale parameters).
  143. X
  144. XThis is the first release of this driver, so please report any bugs (or fixes)
  145. Xto the author (kirk@sdd.hp.com).
  146. X.SH AUTHORS/EDITORS
  147. XKirk Norton, HP San Diego Division (kirk@sdd.hp.com)
  148. X.br
  149. XThanks to
  150. X.br
  151. XCraig Counterman
  152. X.br
  153. XAlan Paeth, University of Waterloo <AWPaeth@watCGL>
  154. X.br
  155. XPoul-Henning Kamp
  156. X
  157. END_OF_FILE
  158.   if test 3527 -ne `wc -c <'starhp.1'`; then
  159.     echo shar: \"'starhp.1'\" unpacked with wrong size!
  160.   fi
  161.   # end of 'starhp.1'
  162. fi
  163. if test -f 'starhp.c.A' -a "${1}" != "-c" ; then 
  164.   echo shar: Will not clobber existing file \"'starhp.c.A'\"
  165. else
  166.   echo shar: Extracting \"'starhp.c.A'\" \(31028 characters\)
  167.   sed "s/^X//" >'starhp.c.A' <<'END_OF_FILE'
  168. X/*
  169. X * starhp.c
  170. X *    HP-GL/2 driver for producing A to E size star maps, color or monochrome.
  171. X *
  172. X * This driver should support all HP Laserjet IIP's, III's (or higher), and any 
  173. X * other HP-GL/2 (or PCL-5) printers and plotters (pen, electrostatic, etc.).  
  174. X * HP-GL devices (usually the older ones) may have some problems, but
  175. X * I've tried to keep the driver as general as possible.
  176. X *
  177. X * This driver WILL NOT support DeskJet, PaintJet (without the HP-GL/2 option),
  178. X *  or early LaserJets (those before IIP's), since these are PCL-only devices
  179. X *  -- so don't try it (because you will get many, many pages of garbage).
  180. X *
  181. X * Some HP-GL/2 LaserJets and compatibles will not be able to print high density
  182. X * charts (ones with lots of stars) due to insufficient memory, and the page
  183. X * may be only partially printed.  To avoid this, either reduce the scale
  184. X * parameter on the starhp command line or reduce the magnitude limits, thereby
  185. X * reducing the number of objects appearing on the page.
  186. X *
  187. X * HP-GL/2 plotters shouldn't have these problems since they print "on the fly".
  188. X * Of course, "haloing" of objects is not supported on pen plotters, and the 
  189. X * nice looking fonts will probably not be available on most large format 
  190. X * devices or on some HP-GL/2 ink jet printers.
  191. X * 
  192. X *
  193. X * Produced by Kirk Norton (kirk@sdd.hp.com) July, 1991 for StarChart 3.2
  194. X * by Alan Paeth and Craig Counterman.  Leveraged (heavily) from starpost.c.
  195. X *
  196. X * Supports the following enhancements:
  197. X *   1> "bigmaster" chart layout now added
  198. X *   2> extensive rework and subclassing of non-stellar objects, e.g.
  199. X *      galaxies, now have both spiral and irregular variants.
  200. X *   3> star sizes now extended to magnitude 10
  201. X *   4> supports large format devices (up to 44x34 inches) 
  202. X *
  203. X * Default size changed from 8x11 to 8x10 inches to accomodate Laserjets
  204. X *
  205. X * StarChart Version 3.2 copyright (c) March 1990 by Craig Counterman 
  206. X * original StarChart Software Suite copyright (c) 1987 by Alan Paeth
  207. X *
  208. X * All rights reserved. Redistribution granted for non-commercial
  209. X * non-profit use only. Disclaimer: users of this work understand that
  210. X * (a) the authors cannot undertake to support this software (b) users
  211. X * agree to acknowledge the use of the software in any published work
  212. X * arising from its application and (c) any subsequent redistribution of
  213. X * this work retains this warranty placard. 
  214. X *
  215. X * No representation is made about the suitability of this
  216. X * software for any purpose.  It is provided "as is" without express or
  217. X * implied warranty, to the extent permitted by applicable law.
  218. X *
  219. X */
  220. X
  221. Xstatic char rcsid[]="$Header: starhp.c,v 1.0 91/05/25 00:34:23 ccount Exp $";
  222. X#include <stdio.h>
  223. X#include <math.h>
  224. X#ifndef SYSV
  225. X#include <strings.h>
  226. X#else
  227. X#include <string.h>
  228. X#endif
  229. X#include <ctype.h>
  230. X#include "star3.h"
  231. X
  232. X
  233. X/* Externs */
  234. Xextern int g_argc;
  235. Xextern char **g_argv;
  236. X
  237. Xextern char *title;    /* Title of page */
  238. X
  239. Xextern mapwindow *mapwin[MAXWINDOWS];
  240. Xextern int numwins;
  241. X
  242. Xextern int cur_function;
  243. Xextern int cur_map_type;
  244. Xextern int cur_map_tag;
  245. Xextern char *cur_tag_field;
  246. Xextern mapwindow *cur_win;
  247. X
  248. Xextern int chart_type;
  249. X
  250. X/* Set by initxform
  251. X   One could use elements of the mapwindow structure,
  252. X   but these should be faster for the current window */
  253. Xextern double xf_west, xf_east, xf_north, xf_south, xf_bottom;
  254. Xextern int xf_xcen, xf_ycen, xf_ybot;
  255. Xextern int xf_w_left, xf_w_right, xf_w_top, xf_w_bot;
  256. Xextern double xf_c_scale;
  257. X
  258. X/* Scale multiplier, minimum,
  259. X   mangitude change, maximum, for thumbnail,*/
  260. X#define THSMUL 1.2
  261. X#define THSMIN 12.0
  262. X#define THMADJ 2.5
  263. X#define THMMAX 8.0
  264. X
  265. X
  266. X#define ResPT 42          /* Changed from 4 in the Postscript driver         */
  267. X#define InchPT 72*ResPT   /* InchPT will still be 1 inch in units for A-size */
  268. X
  269. X#define MAG_1_RAD 9*ResPT
  270. X#define MAG0_RAD ((int)(8*ResPT))
  271. X#define MAG1_RAD ((int)(7*ResPT))
  272. X#define MAG2_RAD ((int)(6*ResPT))
  273. X/*  if MAG3 is not an integer times ResPT,
  274. X    there is an error reported later using some (non-ansi) compilers */
  275. X#define MAG3_RAD ((int)(5*ResPT))
  276. X#define MAG4_RAD ((int)(4*ResPT))
  277. X#define MAG5_RAD ((int)(3.25*ResPT))
  278. X#define MAG6_RAD ((int)(2.5*ResPT))
  279. X#define MAG7_RAD ((int)(2.0*ResPT))
  280. X#define MAG8_RAD ((int)(1.5*ResPT))
  281. X#define MAG9_RAD ((int)(1.0*ResPT))
  282. X#define MAG10_RAD ((int)(0.5*ResPT))
  283. X#define MAG11_RAD ((int)(0.5*ResPT))
  284. X#define MAG12_RAD ((int)(0.5*ResPT))
  285. X#define MAG13_RAD ((int)(0.5*ResPT))
  286. X#define MAG14_RAD ((int)(0.5*ResPT))
  287. X#define MAG15_RAD ((int)(0.5*ResPT))
  288. X#define MAG16_RAD ((int)(0.5*ResPT))
  289. X#define MAG17_RAD ((int)(0.5*ResPT))
  290. X#define MAG18_RAD ((int)(0.5*ResPT))
  291. X#define MAG19_RAD ((int)(0.5*ResPT))
  292. X#define MAG20_RAD ((int)(0.5*ResPT))
  293. X
  294. X#define MAG_NUMMAGS 40
  295. X/* Large enough to hold to mag. 40 */
  296. X
  297. X/* Many things break if MAG_BRIGHT != -1; sorry, Sirius */
  298. X#define MAG_BRIGHT -1
  299. X#define MAG_DIM 20
  300. X
  301. Xstatic int magsizes[MAG_NUMMAGS]; /* Set in D_open or in D_control_arg */
  302. X
  303. X/* mag10: 10 refers to 1/10th magnitude binning */
  304. X#define MAG_10_NUMMAGS MAG_NUMMAGS*10 + 1
  305. Xstatic int mag10sizes[MAG_10_NUMMAGS];
  306. X
  307. X/* For Young's formula */
  308. Xstatic double young_k = 0.11;
  309. Xstatic double young_D0 = 0.5 * ResPT;
  310. Xstatic double young_v0 = 10.0;
  311. Xstatic int use_v0 = FALSE;
  312. Xstatic int use_young = FALSE;
  313. X
  314. X/* Notebook mode controls */
  315. X/* number of eyepiece/finder views */
  316. X#define NOTE_NUMVIEWS 20
  317. Xstatic double viewrad[NOTE_NUMVIEWS];
  318. Xstatic int numviews;
  319. Xstatic int notebook_mode = FALSE;
  320. X
  321. X/* brightest and faintest magnitudes used in first map */
  322. Xstatic double brightest_used = 100.0, faintest_used = -1.0;
  323. X/* used in legend */
  324. Xmapwindow legend_window;
  325. X
  326. X/* shift thumbscale map magnitude */
  327. Xstatic double thumbshift = 0.0;
  328. X
  329. X#ifndef MAXPATHLEN
  330. X#define MAXPATHLEN 1025
  331. X#endif
  332. X
  333. Xstatic char filname[MAXPATHLEN] = "";
  334. Xstatic FILE *set_out_file = NULL;
  335. Xstatic FILE *outf;
  336. X
  337. X/* Status variables */
  338. Xstatic int cur_colr = -1;
  339. Xstatic int c_font = -1, c_size = -1;
  340. Xstatic int cur_x = -1, cur_y = -1;
  341. Xstatic int cur_sty = SOLID;
  342. Xstatic int radii_set = FALSE;
  343. X
  344. X/* Set value to draw smooth circles with minimum number of chords */
  345. Xstatic int curve_val = ResPT / 3;
  346. X
  347. X
  348. X                       /* Physical Plot Size Constants */
  349. X#define MAX_SIZE  0   
  350. X#define A_SIZE    1
  351. X#define B_SIZE    2  
  352. X#define C_SIZE    3 
  353. X#define D_SIZE    4
  354. X#define E_SIZE    5 
  355. X
  356. X            /* Plot dimensions in HP-GL/2 plotter units (1016 pu/inch) */
  357. X            /* A-size = 8.5"x11" paper (usually an 8"x10" print area)  */
  358. X            /* B-size = 11"x17"   (The print areas of B through E      */
  359. X            /* C-size = 17"x22"    size media is usually about one     */
  360. X            /* D-size = 22"x34"    inch shorter in each axis than the  */
  361. X            /* E-size = 34"x44"    physical paper dimensions.)         */
  362. X
  363. Xstatic int plot_length[] = { -1, 10160, 16256, 21336, 33528, 43688 }; 
  364. Xstatic int plot_width[]  = { -1,  8128, 10160, 16256, 21336, 33528 };
  365. Xstatic int plot_size = MAX_SIZE;
  366. Xstatic double scaling_factor = 1;    /* Used for adjusting plot sizes */
  367. X
  368. X
  369. Xdouble plot_scale()    /* Calculates the scale of the selected plot size */
  370. X     {                 /* relative to an A-size (8.5x11) plot.           */
  371. X     double scale;
  372. X     if( plot_size >= A_SIZE && plot_size <= E_SIZE )
  373. X          {
  374. X          double A_xlen, A_ylen, cur_xlen, cur_ylen;
  375. X          double A_diagonal, cur_diagonal;
  376. X
  377. X          A_xlen = (double) plot_length[ A_SIZE ];
  378. X          A_ylen = (double) plot_width[ A_SIZE ];
  379. X          cur_xlen = (double) plot_length[ plot_size ];
  380. X          cur_ylen = (double) plot_width[ plot_size ];
  381. X
  382. X          A_diagonal = sqrt( A_xlen*A_xlen + A_ylen*A_ylen );
  383. X          cur_diagonal = sqrt( cur_xlen*cur_xlen + cur_ylen*cur_ylen );
  384. X
  385. X          scale = A_diagonal / cur_diagonal;
  386. X          return( scale );
  387. X          }
  388. X     else
  389. X          {
  390. X          scale = 1;
  391. X          return( scale );
  392. X          }
  393. X     }
  394. X
  395. X
  396. X                       /* Constants used in font selection */
  397. X
  398. X#define CS_STANDARD 277     /* Font character set codes */
  399. X#define CS_MATH8    269
  400. X
  401. X#define SW_MEDIUM 0         /* Font stroke weight codes */
  402. X#define SW_BOLD   3
  403. X
  404. X#define FP_UPRIGHT 0        /* Font posture codes */
  405. X#define FP_ITALIC  1
  406. X
  407. X#define TF_TMSRMN  5        /* Font typeface codes */
  408. X#define TF_UNIVERS 25
  409. X#define TF_COURIER 3
  410. X
  411. X#define UNDEFINED (-999)
  412. X
  413. X#define PEN_UP     1
  414. X#define PEN_DOWN   2
  415. X
  416. Xstatic int f_charset = CS_STANDARD; /* Default to standard Times-Roman font */
  417. Xstatic int f_sweight = SW_MEDIUM;
  418. Xstatic int f_posture = FP_UPRIGHT;
  419. Xstatic int f_typeface = TF_TMSRMN;
  420. Xstatic int f_size = 12;
  421. X
  422. Xstatic int c_f_charset = UNDEFINED;
  423. Xstatic int c_f_sweight = UNDEFINED;
  424. Xstatic int c_f_posture = UNDEFINED;
  425. Xstatic int c_f_typeface = UNDEFINED;
  426. Xstatic int c_f_size = UNDEFINED;
  427. X
  428. X
  429. X/* The following dimensional information specifies the number of units */
  430. X/* in each of the x- and y-axes, and the x- and y-offsets for each of  */
  431. X/* the different size maps.  For A-size (8.5"x11") charts, there are   */
  432. X/* 3024 units per inch, each ResPT is 1/72 inch, and each InchPT is    */
  433. X/* one inch.  As page sizes increase, these numbers change.  For       */
  434. X/* E-size (34"x44") plots for instance, there about 760 units per      */
  435. X/* inch, each ResPT about is 1/18 inch, and each InchPT is roughly     */
  436. X/* four inches.                                                        */
  437. X
  438. X/* Exports */
  439. X
  440. X/* Full page map:  7"x9.5", y-offset=1/2 inch, x-offset = 1/4 inch */
  441. Xmapwindow fullpage = { 7*InchPT, 9.5*InchPT, 0.5*InchPT, 0.125*InchPT,
  442. X                       8.0, 3.0, 2.05, FULLPAGEMAP, 0, "String",
  443. X                       SANSONS, FALSE, FALSE, 7.5, 5.0, 0.0, 0.0, FALSE };
  444. X
  445. X/* Main map:       7"x7",   y-offset=1/4 inch, x-offset = 2.75 inches */
  446. Xmapwindow mainmap = {  7*InchPT, 7*InchPT, 0.25*InchPT, 2.75*InchPT,
  447. X                       8.0, 3.0, 2.05, MAINMAP, 0, "String",
  448. X                       SANSONS, FALSE, FALSE, 7.5, 5.0, 0.0, 0.0, FALSE };
  449. X
  450. X/* Thumb map:      3.5"x2",   y-offset=3.57 inches, x-offset = 0.25 inch */
  451. Xmapwindow thumbmap = { 3.5*InchPT, 2*InchPT, 3.75*InchPT, 0.25*InchPT,
  452. X                       6.2+THMADJ, 1.0+THMADJ, 2.05+THMADJ, 
  453. X                       THUMBNAIL, 0,"String", SANSONS, FALSE, FALSE, 7.5, 5.0,
  454. X                       0.0, 0.0, FALSE };
  455. X
  456. X/* h & v tick text controls */
  457. Xint htick_lim = 1*ResPT;
  458. Xint htext_lim = 36*ResPT;
  459. Xint htext_xoff = 0*ResPT;
  460. Xint htext_yoff = 10*ResPT;
  461. Xint vtick_lim = 1*ResPT;
  462. Xint vtext_lim = 10*ResPT;
  463. Xint vtext_xoff = 9*ResPT;
  464. Xint vtext_yoff = 0*ResPT;
  465. X
  466. X/* Variables used for legend generation */
  467. Xint x_nameoffset = MAG0_RAD+ResPT, y_nameoffset = 0;
  468. Xint x_lbloffset = MAG3_RAD, y_lbloffset = MAG3_RAD+ResPT/2;
  469. Xint x_magoffset = MAG3_RAD+ResPT, y_magoffset = -MAG3_RAD-ResPT;
  470. X
  471. X
  472. X/* Scale multiplier, minimum,
  473. X   mangitude change, maximum, for thumbnail,*/
  474. Xdouble th_smul=THSMUL;
  475. Xdouble th_smin=THSMIN;
  476. Xdouble th_madj=THMADJ;
  477. Xdouble th_mmax=THMMAX;
  478. X
  479. X#define MAX(a,b) ((a)>(b)?(a):(b))
  480. X#define MIN(a,b) ((a)<(b)?(a):(b))
  481. X
  482. Xvoid out( s )
  483. Xconst char *s;
  484. X     {
  485. X     fprintf( outf, "%s", s );
  486. X     }
  487. X
  488. X#define UNKNOWN -1
  489. X
  490. Xstatic int use_fine_mag = FALSE;   /* Use 10ths of magnitude */
  491. Xstatic int color_hpgl = FALSE;    
  492. Xstatic int landscape = FALSE;
  493. Xstatic int lost = TRUE;            /* Drawing cursor position unclear */
  494. Xstatic int pen_up = UNKNOWN;
  495. X
  496. X                       /* Define color constants */
  497. X
  498. X#define BLACK 0
  499. X#define WHITE 1
  500. X#define RED 2
  501. X#define ORANGE 3
  502. X#define YELLOW 4
  503. X#define GREEN 5
  504. X#define CYAN 6
  505. X#define BLUE 7
  506. X#define VIOLET 8
  507. X#define BLUE_WHITE 9
  508. X
  509. X                       /* Set up spectral class color index table */
  510. X
  511. Xstatic char *table = "OBAFGKMCRNSrgbycpow";
  512. X
  513. Xstatic int super_spectra[][10] = {
  514. X    /*         0   1   2   3   4   5   6   7   8   9   */
  515. X    /* O */ { 32, 32, 32, 32, 32, 32, 32, 32, 32, 32 },
  516. X    /* B */ {  0,  1,  2,  3,  3,  4,  4,  4,  5,  6 },
  517. X    /* A */ {  7,  7,  8,  9,  9, 10, 10, 10, 10, 10 },
  518. X    /* F */ { 11, 11, 12, 12, 12, 13, 13, 13, 14, 14 },
  519. X    /* G */ { 15, 15, 15, 15, 15, 16, 16, 16, 16, 16 },
  520. X    /* K */ { 17, 17, 18, 18, 18, 19, 19, 19, 19, 19 },
  521. X    /* M */ { 20, 20, 21, 22, 23, 24, 25, 26, 26, 26 },
  522. X    /* C */ { 27, 27, 27, 28, 28, 28, 28, 28, 29, 30 },
  523. X    /* R */ { 27, 27, 27, 28, 28, 28, 28, 28, 29, 30 },
  524. X    /* N */ { 27, 27, 27, 28, 28, 28, 28, 28, 29, 30 },
  525. X    /* S */ { 30, 30, 30, 30, 31, 31, 31, 31, 31, 31 },
  526. X    /* r */ { 33, 33, 33, 34, 34, 34, 35, 35, 35, 36 },
  527. X    /* y */ { 37, 37, 37, 38, 38, 38, 39, 39, 39, 40 },
  528. X    /* g */ { 41, 41, 41, 42, 42, 42, 43, 43, 43, 44 },
  529. X    /* c */ { 45, 45, 45, 46, 46, 46, 47, 47, 47, 48 },
  530. X    /* b */ { 49, 49, 49, 50, 50, 50, 51, 51, 51, 52 },
  531. X    /* p */ { 53, 53, 53, 54, 54, 54, 55, 55, 55, 56 },
  532. X    /* o */ { 57, 57, 57, 58, 58, 58, 59, 59, 59, 60 },
  533. X    /* w */ { 61, 61, 61, 62, 62, 62, 63, 63, 63, 64 }
  534. X          };
  535. X
  536. X/*                     Set up RGB color table */
  537. X
  538. X  static struct {double r, g, b;} ctab[] = {
  539. X
  540. X/*            Red  Grn  Blu       Color        */
  541. X
  542. X/*  0 */    { 1.0, 1.0, 1.0 },   /* BLACK */
  543. X/*  1 */    {   0,   0,   0 },   /* WHITE */
  544. X/*  2 */    { 1.0,   0,   0 },   /* RED */
  545. X/*  3 */    { 1.0, 0.4,   0 },   /* ORANGE */
  546. X/*  4 */    { 1.0, 1.0,   0 },   /* YELLOW */
  547. X/*  5 */    {   0, 1.0,   0 },   /* GREEN */
  548. X/*  6 */    {   0, 1.0, 1.0 },   /* CYAN */
  549. X/*  7 */    {   0,   0, 1.0 },   /* BLUE */
  550. X/*  8 */    { 1.0,   0, 1.0 },   /* VIOLET */
  551. X/*  9 */    { .5, .5, 1.0 },     /* BLUE_WHITE */
  552. X
  553. X/*              Red             Green           Blue          Nameby which
  554. X                                                             type is known */
  555. X/* 10 */    { 0.38937,        0.46526,        0.79493 },    /* B0 */
  556. X/* 11 */    { 0.39501,        0.47146,        0.78847 },    /* B1 */
  557. X/* 12 */    { 0.40103,        0.47792,        0.78151 },    /* B2 */
  558. X/* 13 */    { 0.40640,        0.48355,        0.77526 },    /* B3 */
  559. X/* 14 */    { 0.41341,        0.49071,        0.76701 },    /* B5 */
  560. X/* 15 */    { 0.43251,        0.50914,        0.74412 },    /* B8 */
  561. X/* 16 */    { 0.44342,        0.51897,        0.73079 },    /* B9 */
  562. X/* 17 */    { 0.45181,        0.52618,        0.72042 },    /* A0 */
  563. X/* 18 */    { 0.46931,        0.54026,        0.69847 },    /* A2 */
  564. X/* 19 */    { 0.47958,        0.54792,        0.68541 },    /* A3 */
  565. X/* 20 */    { 0.48538,        0.55205,        0.67797 },    /* A5 */
  566. X/* 21 */    { 0.50879,        0.56731,        0.64752 },    /* F0 */
  567. X/* 22 */    { 0.51732,        0.57231,        0.63627 },    /* F2 */
  568. X/* 23 */    { 0.52348,        0.57573,        0.62810 },    /* F5 */
  569. X/* 24 */    { 0.54076,        0.58447,        0.60496 },    /* F8 */
  570. X/* 25 */    { 0.54853,        0.58799,        0.59446 },    /* G0 */
  571. X/* 26 */    { 0.56951,        0.59623,        0.56584 },    /* G5 */
  572. X/* 27 */    { 0.58992,        0.60244,        0.53765 },    /* K0 */
  573. X/* 28 */    { 0.61098,        0.60693,        0.50828 },    /* K2 */
  574. X/* 29 */    { 0.63856,        0.60977,        0.46950 },    /* K5 */
  575. X/* 30 */    { 0.68698,        0.60595,        0.40110 },    /* M0 */
  576. X/* 31 */    { 0.72528,        0.59434,        0.34744 },    /* M2 */
  577. X/* 32 */    { 0.75182,        0.58144,        0.31097 },    /* M3 */
  578. X/* 33 */    { 0.78033,        0.56272,        0.27282 },    /* M4 */
  579. X/* 34 */    { 0.81066,        0.53676,        0.23394 },    /* M5 */
  580. X/* 35 */    { 0.84247,        0.50195,        0.19570 },    /* M6 */
  581. X/* 36 */    { 0.87512,        0.45667,        0.16004 },    /* M7 */
  582. X/* 37 */    { 0.71033,        0.59983,        0.36829 },    /* N0 */
  583. X/* 38 */    { 0.78625,        0.55816,        0.26507 },    /* N3 */
  584. X/* 39 */    { 0.93792,        0.33011,        0.10649 },    /* N8 */
  585. X/* 40 */    { 0.94897,        0.29906,        0.10012 },    /* N9 */
  586. X/* 41 */    { 0.79832,        0.54811,        0.24950 },    /* S4 */
  587. X/* 42 */    { 0.38241,        0.45743,        0.80282 },    /* O  */
  588. X
  589. X/*                R  G  B             Color and intensity */
  590. X
  591. X/* 43 */    { 0.500, 0, 0},              /* r0 */
  592. X/* 44 */    { 0.750, 0, 0},              /* r3 */
  593. X/* 45 */    { 0.875, 0, 0},              /* r6 */
  594. X/* 46 */    { 1.000, 0, 0},              /* r9 */
  595. X/* 47 */    { 0, 0.500, 0},              /* g0 */
  596. X/* 48 */    { 0, 0.750, 0},              /* g3 */
  597. X/* 49 */    { 0, 0.875, 0},              /* g6 */
  598. X/* 50 */    { 0, 1.000, 0},              /* g9 */
  599. X/* 51 */    { 0, 0, 0.500},              /* b0 */
  600. X/* 52 */    { 0, 0, 0.750},              /* b3 */
  601. X/* 53 */    { 0, 0, 0.875},              /* b6 */
  602. X/* 54 */    { 0, 0, 1.000},              /* b9 */
  603. X/* 55 */    { 0.500, 0.500, 0},          /* y0 */
  604. X/* 56 */    { 0.750, 0.750, 0},          /* y3 */
  605. X/* 57 */    { 0.875, 0.875, 0},          /* y6 */
  606. X/* 58 */    { 1.000, 1.000, 0},          /* y9 */
  607. X/* 59 */    { 0, 0.500, 0.500},          /* c0 */
  608. X/* 60 */    { 0, 0.750, 0.750},          /* c3 */
  609. X/* 61 */    { 0, 0.875, 0.875},          /* c6 */
  610. X/* 62 */    { 0, 1.000, 1.000},          /* c9 */
  611. X/* 63 */    { 0.500, 0, 0.500},          /* p0 */
  612. X/* 64 */    { 0.750, 0, 0.750},          /* p3 */
  613. X/* 65 */    { 0.875, 0, 0.875},          /* p6 */
  614. X/* 66 */    { 1.000, 0, 1.000},          /* p9 */
  615. X/* 67 */    { 0.500, 0.250, 0.000},      /* o0 */
  616. X/* 68 */    { 0.750, 0.375, 0.000},      /* o3 */
  617. X/* 69 */    { 0.875, 0.4375, 0.000},     /* o6 */
  618. X/* 70 */    { 1.000, 0.500, 0.000},      /* o9 */
  619. X/* 71 */    { 0.500, 0.500, 0.500},      /* w0 */
  620. X/* 72 */    { 0.750, 0.750, 0.750},      /* w3 */
  621. X/* 73 */    { 0.875, 0.875, 0.875},      /* w6 */
  622. X/* 74 */    { 1.000, 1.000, 1.000},      /* w9 */
  623. X          };
  624. X
  625. X
  626. X/* Store star RGB color values in HP-GL/2 pen color table */
  627. Xvoid store_colors()
  628. X     {
  629. X     int pen = 0;
  630. X
  631. X     if( color_hpgl == FALSE )
  632. X          return;
  633. X
  634. X     fprintf( outf, "\nCO \"Define star color spectra table:\"\n" );
  635. X     for( pen = 0 ; pen <= 74 ; pen++ )
  636. X          fprintf( outf, "PC%2d,%3.0f,%3.0f,%3.0f;\n", pen, 
  637. X                          ctab[pen].r*255, ctab[pen].g*255, ctab[pen].b*255 );
  638. X     }
  639. X
  640. X
  641. X/* Rotate coordinate (x,y) through angle theta */
  642. Xvoid rotate( x, y, theta )
  643. Xint *x, *y;
  644. Xdouble theta;
  645. X     {
  646. X     double x1, y1, a;
  647. X
  648. X     a = theta * 0.0174532925199;
  649. X     x1 = (double) *x;  
  650. X     y1 = (double) *y;
  651. X
  652. X     *x = (int) (x1 * cos(a) - y1 * sin(a));
  653. X     *y = (int) (y1 * cos(a) + x1 * sin(a));
  654. X     }
  655. X
  656. X
  657. X/* Draw from current pen postition to rotated coordinate position */
  658. Xvoid draw_rot( x, y, theta, state )
  659. Xint x, y, state;
  660. Xdouble theta;
  661. X     {
  662. X     double x1, y1, a;
  663. X  
  664. X     a = theta * 0.0174532925199; 
  665. X     x1 = (double) x * cos(a) - (double) y * sin(a);
  666. X     y1 = (double) y * cos(a) + (double) x * sin(a);
  667. X
  668. X     if( state == PEN_UP )
  669. X          fprintf( outf, "PU%.0f,%.0f", x1, y1 );
  670. X     else
  671. X          fprintf( outf, "PD%.0f,%.0f", x1, y1 );
  672. X     }
  673. X
  674. X
  675. X/* Device control argument */
  676. XD_control_arg(s)
  677. Xchar *s;
  678. X{
  679. X  int i = 0, j, k;
  680. X  int c;
  681. X  char *cp;
  682. X
  683. X  i = 0;
  684. X  while (c = s[i++]) switch (c) {
  685. X  case 'm':
  686. X    /* m [mag-1 : mag0 : mag1 : mag2 : ...] */
  687. X    use_fine_mag = TRUE;
  688. X    if (s[i]) {
  689. X      cp = &s[i];
  690. X      /* Skip leading white space */
  691. X      while ((*cp == ' ') || (*cp == '\t')) {
  692. X        i++;
  693. X        cp++;
  694. X      }
  695. X      j = 0;
  696. X      while (*cp) {
  697. X        radii_set = TRUE;
  698. X        if (j < MAG_NUMMAGS) magsizes[j++] = atof(cp) * ResPT;
  699. X        while (isdigit(*cp) || (*cp == '.')) {
  700. X          i++;
  701. X          cp++;
  702. X        }
  703. X        if (*cp) cp++;
  704. X      }
  705. X      for (k = j;k < MAG_NUMMAGS; k++)
  706. X        magsizes[k] = magsizes[j];
  707. X    }
  708. X    break;
  709. X  case 'f':
  710. X    /* f [file] */
  711. X    if (s[i++] == ' ')
  712. X      if (s[i])
  713. X        strcpy(filname, &s[i]);
  714. X    while ((s[i]) && (s[i] != ' ')) i++;
  715. X    break;
  716. X  case 'c':
  717. X    /* c */
  718. X    color_hpgl = TRUE;
  719. X    break;
  720. X  case 'l':
  721. X    /* l */
  722. X    landscape = TRUE;
  723. X    chart_type = FULLPAGE;
  724. X    break;
  725. X  case 'n':   
  726. X              /* n [rad1 : rad2 : rad3 : ... ] */
  727. X   notebook_mode = TRUE;
  728. X   chart_type = THREEPART;
  729. X   j = 0;
  730. X   if( s[i] )
  731. X        {
  732. X        cp = &s[i];
  733. X        /* Skip leading white spaces */
  734. X        while ((*cp == ' ') || (*cp == '\t')) {
  735. X             i++;
  736. X             cp++;
  737. X             }
  738. X        while ((*cp) && (isdigit(*cp) || (*cp == '.'))) {
  739. X             if (j < NOTE_NUMVIEWS) viewrad[j++] = atof(cp)/2.0;
  740. X                                             /* It's input as diameter */
  741. X             while (isdigit(*cp) || (*cp == '.')) {
  742. X                  i++;
  743. X                  cp++;
  744. X                  }
  745. X             if (*cp) cp++;
  746. X             }
  747. X        }
  748. X   numviews = j;
  749. X   break;
  750. X  case 'A':  /* A size chart */
  751. X    plot_size = A_SIZE;
  752. X    break;
  753. X  case 'B':  /* B size chart */
  754. X    plot_size = B_SIZE;
  755. X    break;
  756. X  case 'C':  /* C size chart */
  757. X    plot_size = C_SIZE;
  758. X    break;
  759. X  case 'D':  /* D size chart */
  760. X    plot_size = D_SIZE;
  761. X    break;
  762. X  case 'E':  /* E size chart */
  763. X    plot_size = E_SIZE;
  764. X    break;
  765. X  case 'L':  /* Scale plot for LaserJets */
  766. X    plot_size = MAX_SIZE;
  767. X    break;
  768. X  default:
  769. X    break;
  770. X  }
  771. X}
  772. X
  773. X
  774. X/* Open the device */
  775. XD_open()
  776. X{
  777. X  int i, j;
  778. X  int hshift, vshift;
  779. X  double young_size;
  780. X
  781. X  if (filname[0] != '\0') {
  782. X    set_out_file = fopen(filname, "w");
  783. X  };
  784. X   if (set_out_file != NULL)
  785. X    outf = set_out_file;
  786. X  else
  787. X    outf = stdout;      /* WARNING: This might not work on some systems */
  788. X
  789. X  /* Need to initialize all variables */
  790. X  cur_colr = -1;
  791. X  c_font = -1;
  792. X  c_size = -1;
  793. X  cur_x = -1;
  794. X  cur_y = -1;
  795. X
  796. X  scaling_factor = plot_scale();
  797. X
  798. X                          /* Initialize plotter for HP-GL/2 mode */
  799. X
  800. X  out( "\033%-1BBPIN;\n\n" );
  801. X  out( "CO \"Star map generated with StarChart version 3.2 \n" );
  802. X  out( "    by Alan Paeth and Craig Counterman \n" );
  803. X  out( "    using the HP-GL/2 driver StarHP version 1.0 \n" );
  804. X  out( "    by Kirk Norton (kirk@sdd.hp.com).\";\n\n" );
  805. X
  806. X                               /* Set page size and scaling */
  807. X  if( A_SIZE <= plot_size && plot_size <= E_SIZE )
  808. X       {
  809. X       fprintf( outf, "PS%d,%d", plot_length[ plot_size ], plot_width[ plot_size ] );
  810. X       curve_val = (int) ((double) curve_val * scaling_factor);
  811. X       if( plot_size > C_SIZE )
  812. X            curve_val = (int) ((double) curve_val / 1.5);
  813. X       }
  814. X
  815. X  if (landscape && notebook_mode == FALSE) { /* Change scaling for landscape */
  816. X       D_comment( "landscape mode" );
  817. X       hshift = (int) (0.5 * InchPT);
  818. X       vshift = (int) -(0.5 * InchPT);
  819. X       if( plot_size == MAX_SIZE )  
  820. X            out( "RO270;" );
  821. X       else
  822. X            out( "RO0;" );
  823. X       fprintf( outf, "IPSC%d,%d,%d,%d,1;\n", 
  824. X                       hshift, 10*InchPT+hshift, vshift, 8*InchPT+vshift ); 
  825. X       i = fullpage.width;
  826. X       fullpage.width = fullpage.height;
  827. X       fullpage.height = i;
  828. X       }
  829. X  else {
  830. X       if( notebook_mode == FALSE )
  831. X            hshift = (int) (0.25 * InchPT);
  832. X       else
  833. X            hshift = (int) -(0.05 * InchPT);
  834. X       if( chart_type == FULLPAGE )
  835. X            vshift = (int) -(0.15 * InchPT);
  836. X       else
  837. X            vshift = (int) 0;
  838. X       if( plot_size == MAX_SIZE )
  839. X            out( "RO0;" );
  840. X       else
  841. X            out( "RO270;" );
  842. X       fprintf( outf, "IPSC%d,%d,%d,%d,1;\n", 
  843. X                       hshift, 8*InchPT+hshift, vshift, 10*InchPT+vshift ); 
  844. X       }
  845. X
  846. X  out( "TR0NP128LA1,4,2,4DT@QL100CT1UL1,50,50PW0.13;\n" ); 
  847. X
  848. X  cur_x = 0;
  849. X  cur_y = 0;
  850. X  lost = FALSE;
  851. X  cur_sty = SOLID;
  852. X  pen_up = UNKNOWN;
  853. X  store_colors();
  854. X  out( "LTPUPA0,0PRSD2,1SSSP1" );
  855. X
  856. X                             /* Adjust text offsets for current plot size */
  857. X  if( A_SIZE <= plot_size && plot_size <= E_SIZE )
  858. X       {
  859. X       htext_xoff = (int) ((double) htext_xoff * scaling_factor); 
  860. X       htext_yoff = (int) ((double) htext_yoff * scaling_factor);
  861. X       vtext_xoff = (int) ((double) vtext_xoff * scaling_factor);
  862. X       vtext_yoff = (int) ((double) vtext_yoff * scaling_factor);
  863. X       x_nameoffset = (int) ((double) x_nameoffset * scaling_factor);
  864. X       y_nameoffset = (int) ((double) y_nameoffset * scaling_factor);
  865. X       x_lbloffset = (int) ((double) x_lbloffset * scaling_factor);
  866. X       y_lbloffset = (int) ((double) y_lbloffset * scaling_factor);
  867. X       x_magoffset = (int) ((double) x_magoffset * scaling_factor);
  868. X       y_magoffset = (int) ((double) y_magoffset * scaling_factor);
  869. X       }
  870. X                             /* set array of magnitude radii */
  871. X  if (radii_set == FALSE)  
  872. X       {
  873. X       magsizes[0] = MAG_1_RAD;
  874. X       magsizes[1] = MAG0_RAD;
  875. X       magsizes[2] = MAG1_RAD;
  876. X       magsizes[3] = MAG2_RAD;
  877. X       magsizes[4] = MAG3_RAD;
  878. X       magsizes[5] = MAG4_RAD;
  879. X       magsizes[6] = MAG5_RAD;
  880. X       magsizes[7] = MAG6_RAD;
  881. X       magsizes[8] = MAG7_RAD;
  882. X       magsizes[9] = MAG8_RAD;
  883. X       magsizes[10] = MAG9_RAD;
  884. X       magsizes[11] = MAG10_RAD;
  885. X       magsizes[12] = MAG11_RAD;
  886. X       magsizes[13] = MAG12_RAD;
  887. X       magsizes[14] = MAG13_RAD;
  888. X       magsizes[15] = MAG14_RAD;
  889. X       magsizes[16] = MAG15_RAD;
  890. X       magsizes[17] = MAG16_RAD;
  891. X       magsizes[18] = MAG17_RAD;
  892. X       magsizes[19] = MAG18_RAD;
  893. X       magsizes[20] = MAG19_RAD;
  894. X       magsizes[21] = MAG20_RAD;
  895. X       for (i = 22; i < MAG_NUMMAGS; i++)
  896. X            {
  897. X            magsizes[i] = MAG10_RAD;
  898. X            }
  899. X       radii_set = TRUE;
  900. X       }
  901. X
  902. X  /* Thumbshift */
  903. X  if ((numwins == 2) && (mapwin[1]->map_type == THUMBNAIL)) {
  904. X    thumbshift = mapwin[0]->maglim - MIN(th_mmax,
  905. X                                         mapwin[1]->maglim - th_madj);
  906. X  }
  907. X
  908. X
  909. X  if (use_fine_mag) {
  910. X    /* use fine (continuous) magnitude scale */
  911. X
  912. X    if (use_young) {
  913. X      /* set magsizes according to Young's formula,
  914. X         Sky and Telescope, March 1990, p. 311 */
  915. X      if (!use_v0) young_v0 = mapwin[0]->maglim;
  916. X      for (i = 0; i < MAG_10_NUMMAGS; i++) {
  917. X        /* magsizes[i] is for magnitude (i - 1) */
  918. X        /* brightest mag10sizes is for mag -1.0 */
  919. X        young_size = young_D0 * exp(log(10.0)*young_k*(young_v0 - (i/10.0-1)));
  920. X        if (young_size <  1) young_size = 1;
  921. X        mag10sizes[i] = (int) (young_size + 0.5);
  922. X      }
  923. X    } 
  924. X    else {
  925. X      for (i = 0; i < (MAG_NUMMAGS-1); i++)
  926. X        for (j = 0; j < 10; j++)
  927. X          mag10sizes[i*10 + j] =
  928. X            magsizes[i] - j*(magsizes[i] - magsizes[i+1])/10.0;
  929. X      mag10sizes[(MAG_NUMMAGS-1)*10] = magsizes[MAG_NUMMAGS-1];
  930. X      }
  931. X    }
  932. X  return TRUE ;                /* open successful */
  933. X}
  934. X
  935. X
  936. X/* Close the device */
  937. XD_close()                               /* Terminate the HP-GL file */
  938. X{
  939. X  if( notebook_mode == TRUE )
  940. X       add_notes();
  941. X  out( ";PUSP0PG;" );
  942. X  fflush( outf );
  943. X  fclose( outf );
  944. X}
  945. X
  946. X
  947. Xset_line_type( style )       /* Select solid, dashed, or dotted lines */
  948. Xint style;
  949. X     {
  950. X     if( style != cur_sty )
  951. X          {
  952. X          switch( style )
  953. X               {
  954. X               case DOTTED:
  955. X               case VECDOT:
  956. X                 out( "LT1,1,1" );
  957. X                 break;
  958. X               case DASHED:
  959. X               case VECDASH:
  960. X                 out( "LT2,3,1" );
  961. X                 break;
  962. X               default:
  963. X                 out( "LT;" );
  964. X               }
  965. X          pen_up = UNKNOWN;
  966. X          }
  967. X     cur_sty = style;
  968. X     }
  969. X
  970. X
  971. X/* Move to (x, y) */
  972. XD_move(x, y)
  973. X     int x, y;
  974. X{
  975. X  int dx, dy;
  976. X
  977. X  dx = x - cur_x;      /* Get coordinates relative to current position */
  978. X  dy = y - cur_y;
  979. X
  980. X  if( dx == 0 && dy == 0 && lost == FALSE )
  981. X    return;
  982. X
  983. X  if( lost == FALSE )   /* Move relative to current position */
  984. X    {
  985. X    if( pen_up != TRUE )
  986. X      out( "PU" );
  987. X    else 
  988. X      out( "," );
  989. X    fprintf( outf, "%d,%d", dx, dy );
  990. X    cur_x += dx;
  991. X    cur_y += dy;
  992. X    }
  993. X  else                  /* Move to absolute coordinates */
  994. X    {
  995. X    if( pen_up != TRUE )
  996. X      out( "PU" );
  997. X    fprintf( outf, "PA%d,%dPR", x, y );
  998. X    lost = FALSE;
  999. X    cur_x = x;
  1000. X    cur_y = y;
  1001. X    }
  1002. X  pen_up = TRUE;
  1003. X}
  1004. X
  1005. X
  1006. X/* Line to (x, y) */
  1007. Xdraw_line( x, y, style )
  1008. X     int x, y, style;
  1009. X{
  1010. X  int dx, dy;
  1011. X
  1012. X  dx = x - cur_x;      /* Get coordinates relative to current position */
  1013. X  dy = y - cur_y;
  1014. X
  1015. X  if( cur_function == CHRTVTICK || cur_function == CHRTHTICK )
  1016. X    {
  1017. X    dx *= (   ResPT / 4 ); /* This is necessary since the tick function sends */
  1018. X    dy *= ( - ResPT / 4 ); /* absolute length values instead of scaled ones.  */ 
  1019. X                           /*   (It took me forever to track down this one!)  */
  1020. X    if( A_SIZE <= plot_size && plot_size <= E_SIZE )
  1021. X       {
  1022. X       dx = (int) ((double) dx * scaling_factor);
  1023. X       dy = (int) ((double) dy * scaling_factor);
  1024. X       }
  1025. X    }
  1026. X
  1027. X  set_line_type( style );
  1028. X  if( lost == FALSE )   /* Draw relative to current position */
  1029. X    {
  1030. X    if( pen_up != FALSE )
  1031. X      out( "PD" );
  1032. X    else 
  1033. X      out( "," );
  1034. X    fprintf( outf, "%d,%d", dx, dy );
  1035. X    cur_x += dx;
  1036. X    cur_y += dy;
  1037. X    }
  1038. X  else                  /* Draw to absolute coordinates */
  1039. X    {
  1040. X    if( pen_up != FALSE )
  1041. X      out( "PD" );
  1042. X    fprintf( outf, "PA%d,%dPR", x, y );
  1043. X    lost = FALSE;
  1044. X    cur_x = x;
  1045. X    cur_y = y;
  1046. X    }
  1047. X  pen_up = FALSE;
  1048. X}
  1049. X
  1050. X
  1051. X/* Draw a line of style line_style from the current point to (x, y) */
  1052. XD_draw(x, y, line_style)
  1053. X     int x, y;
  1054. X     int line_style;    /* SOLID, DOTTED, DASHED, etc. */
  1055. X{
  1056. X  int sty;
  1057. X
  1058. X  if ((x != cur_x) || (y != cur_y) || (line_style != cur_sty)) {
  1059. X    switch(cur_function) {
  1060. X    case CHRTOUTLN:
  1061. X    case CHRTHTICK:
  1062. X    case CHRTVTICK:
  1063. X      sty = SOLID;
  1064. X      break;
  1065. X    case GRID_RA:
  1066. X    case GRID_DEC:
  1067. X      sty = DOTTED;
  1068. X      break;
  1069. X    case ECLIPT:
  1070. X      sty = DOTTED;
  1071. X      break;
  1072. X    case CONSTBOUND:
  1073. X      sty = DASHED;
  1074. X      break;
  1075. X    case CONSTPATTRN:
  1076. X      sty = SOLID;
  1077. X      break;
  1078. X    case CONSTNAME:
  1079. X    case CHARTFILE:
  1080. X    default:
  1081. X      sty = line_style;
  1082. X      break;
  1083. X    }
  1084. X  if( cur_colr == UNKNOWN )
  1085. X    {
  1086. X    out( "SP1" );
  1087. X    cur_colr = 1;
  1088. X    }
  1089. X  draw_line( x, y, sty );
  1090. X  }
  1091. X}
  1092. X/* This routine is encouraged to look at the extern cur_funtion
  1093. X   and change the line style drawn as desired */
  1094. X
  1095. X
  1096. X/* Move to (x1, y1) then draw a line of style line_style to (x2, y2) */
  1097. XD_movedraw(x1, y1, x2, y2, line_style)
  1098. X     int x1, y1, x2, y2;
  1099. X     int line_style;    /* SOLID, DOTTED, DASHED, etc. */
  1100. X{
  1101. X  D_move(x1, y1);
  1102. X  D_draw(x2, y2, line_style);
  1103. X}
  1104. X
  1105. Xstatic struct {int x,y;} areapts[1000];
  1106. Xstatic int nareapts;
  1107. X/* Move to (x, y) to begin an area */
  1108. XD_areamove(x, y)
  1109. X     int x, y;
  1110. X{
  1111. X  nareapts = 0;
  1112. X  areapts[nareapts].x = x;
  1113. X  areapts[nareapts].y = y;
  1114. X  nareapts++;
  1115. X}
  1116. X
  1117. X/* Add a segment to the area border */
  1118. XD_areaadd(x, y)
  1119. X     int x, y;
  1120. X{
  1121. X  areapts[nareapts].x = x;
  1122. X  areapts[nareapts].y = y;
  1123. X  nareapts++;
  1124. X}
  1125. X
  1126. X/* Fill the area, after adding the last segment */
  1127. XD_areafill(x, y)
  1128. X     int x, y;
  1129. X{
  1130. X  int i;
  1131. X
  1132. X  areapts[nareapts].x = x;
  1133. X  areapts[nareapts].y = y;
  1134. X  nareapts++;
  1135. X
  1136. X
  1137. X  D_move(areapts[0].x, areapts[0].y);
  1138. X  out( "PM0" );
  1139. X
  1140. X  for (i = 1; i < nareapts; i++)
  1141. X    draw_line( areapts[i].x, areapts[i].y, cur_sty );
  1142. X  out( "PM2FP" );
  1143. X  pen_up = UNKNOWN;
  1144. X
  1145. X}
  1146. X
  1147. X
  1148. X
  1149. X/* Set the color to be used for lines and text */
  1150. X/* color_str is a 2 char (+ '\0') string containing
  1151. X   a specification for a color,
  1152. X   e.g. "G2" for the color of a star of spectral class G2, or "r7" for
  1153. X   red, level seven.  The interpretation of the color string is left to
  1154. X   the device driver */
  1155. XD_color(color_str)
  1156. Xchar *color_str;
  1157. X     {
  1158. X     int class, subclass, colr;
  1159. X     if( color_hpgl == FALSE )
  1160. X          {
  1161. X          if( cur_colr != 1 )
  1162. X               {
  1163. X               out( "SP1" );
  1164. X               pen_up = UNKNOWN;
  1165. X               cur_colr = 1;
  1166. X               }
  1167. X          return;
  1168. X          }
  1169. X
  1170. END_OF_FILE
  1171.   if test 31028 -ne `wc -c <'starhp.c.A'`; then
  1172.     echo shar: \"'starhp.c.A'\" unpacked with wrong size!
  1173.   elif test -f 'starhp.c.B'; then
  1174.     echo shar: Combining  \"'starhp.c'\" \(67818 characters\)
  1175.     cat 'starhp.c.A' 'starhp.c.B' > 'starhp.c'
  1176.     if test 67818 -ne `wc -c <'starhp.c'`; then
  1177.       echo shar: \"'starhp.c'\" combined with wrong size!
  1178.     else
  1179.       rm starhp.c.A starhp.c.B
  1180.     fi
  1181.   fi
  1182.   # end of 'starhp.c.A'
  1183. fi
  1184. echo shar: End of archive 2 \(of 2\).
  1185. cp /dev/null ark2isdone
  1186. MISSING=""
  1187. for I in 1 2 ; do
  1188.     if test ! -f ark${I}isdone ; then
  1189.     MISSING="${MISSING} ${I}"
  1190.     fi
  1191. done
  1192. if test "${MISSING}" = "" ; then
  1193.     echo You have unpacked both archives.
  1194.     rm -f ark[1-9]isdone
  1195. else
  1196.     echo You still must unpack the following archives:
  1197.     echo "        " ${MISSING}
  1198. fi
  1199. exit 0
  1200. exit 0 # Just in case...
  1201.