home *** CD-ROM | disk | FTP | other *** search
/ The UNIX CD Bookshelf / OREILLY_TUCB_UNIX_CD.iso / upt / examples / SOURCES / IPL / PART10.Z / PART10
Encoding:
Text File  |  1998-07-24  |  35.8 KB  |  969 lines

  1. Subject:  v21i041:  2D graphic system with table beautifier, Part10/14
  2. Newsgroups: comp.sources.unix
  3. Approved: rsalz@uunet.UU.NET
  4. X-Checksum-Snefru: 3c92451a cf1911e5 4faeb657 5c05c1a5
  5.  
  6. Submitted-by: Steve Grubb <uunet!lsr-vax!scg>
  7. Posting-number: Volume 21, Issue 41
  8. Archive-name: ipl/part10
  9.  
  10. # ipl part10
  11. #    This is a shell archive.
  12. #    Remove everything above and including the cut line.
  13. #    Then run the rest of the file through sh.
  14. #---------------------- cut here -----------------------------
  15. #!/bin/sh
  16. # shar:    Shell Archiver
  17. #    Run the following text with /bin/sh to create:
  18. #        src/shading.h
  19. #        src/siplmenu.c
  20. #        src/sunv.c
  21. #        src/template.h
  22. #        src/text.c
  23. cat << \SHAR_EOF > src/shading.h
  24.  
  25. /* shading .... */
  26. static short w_im_00[] = {        /* black */
  27. #include <images/square_black.pr> 
  28. };
  29. mpr_static( w_s_00, 16, 16, 1, w_im_00 );
  30.  
  31. static short w_im_10[] = {
  32. /* Format_version=1, Width=16, Height=16, Depth=1, Valid_bits_per_item=16
  33.  */
  34.     0x7F7F,0xFFFF,0xF7F7,0xFFFF,0x7F7F,0xFFFF,0xF7F7,0xFFFF,
  35.     0x7F7F,0xFFFF,0xF7F7,0xFFFF,0x7F7F,0xFFFF,0xF7F7,0xFFFF
  36. };
  37. mpr_static( w_s_10, 16, 16, 1, w_im_10 );
  38.  
  39.  
  40. static short w_im_20[] = {
  41. /* Format_version=1, Width=16, Height=16, Depth=1, Valid_bits_per_item=16
  42.  */
  43.     0x7777,0xFFFF,0x7777,0xFFFF,0x7777,0xFFFF,0x7777,0xFFFF,
  44.     0x7777,0xFFFF,0x7777,0xFFFF,0x7777,0xFFFF,0x7777,0xFFFF
  45. };
  46. mpr_static( w_s_20, 16, 16, 1, w_im_20 );
  47.  
  48. static short w_im_30[] = {
  49. /* Format_version=1, Width=16, Height=16, Depth=1, Valid_bits_per_item=16
  50.  */
  51.     0x7DF7,0xDF7D,0xFBEF,0xEFBE,0xBEFB,0xF7DF,0x7DF7,0xDF7D,
  52.     0xFBEF,0xEFBE,0xBEFB,0xF7DF,0x7DF7,0xDF7D,0xFBEF,0xEFBE
  53. } ;
  54. mpr_static( w_s_30, 16, 16, 1, w_im_30 );
  55.  
  56. static short w_im_40[] = {
  57. /* Format_version=1, Width=16, Height=16, Depth=1, Valid_bits_per_item=16
  58.  */
  59.     0x7777,0xDDDD,0x7777,0xDDDD,0x7777,0xDDDD,0x7777,0xDDDD,
  60.     0x7777,0xDDDD,0x7777,0xDDDD,0x7777,0xDDDD,0x7777,0xDDDD
  61. } ;
  62. mpr_static( w_s_40, 16, 16, 1, w_im_40 );
  63.  
  64. static short w_im_50[] = {
  65. /* Format_version=1, Width=16, Height=16, Depth=1, Valid_bits_per_item=16
  66.  */
  67.     0xEEEE,0xAAAA,0xAAAA,0xBBBB,0xEEEE,0xAAAA,0xAAAA,0xBBBB,
  68.     0xEEEE,0xAAAA,0xAAAA,0xBBBB,0xEEEE,0xAAAA,0xAAAA,0xBBBB
  69. };
  70. mpr_static( w_s_50, 16, 16, 1, w_im_50 );
  71.  
  72. static short w_im_60[] = {
  73. /* Format_version=1, Width=16, Height=16, Depth=1, Valid_bits_per_item=16
  74.  */
  75.     0x5555,0x5555,0x5555,0x5555,0x5555,0x5555,0x5555,0x5555,
  76.     0x5555,0x5555,0x5555,0x5555,0x5555,0x5555,0x5555,0x5555
  77. };
  78. mpr_static( w_s_60, 16, 16, 1, w_im_60 );
  79.  
  80. static short w_im_70[] = {
  81. /* Format_version=1, Width=16, Height=16, Depth=1, Valid_bits_per_item=16
  82.  */
  83.     0x8888,0x2222,0x8888,0x2222,0x8888,0x2222,0x8888,0x2222,
  84.     0x8888,0x2222,0x8888,0x2222,0x8888,0x2222,0x8888,0x2222
  85. };
  86. mpr_static( w_s_70, 16, 16, 1, w_im_70 );
  87.  
  88. static short w_im_80[] = {
  89. #include <images/square_17.pr>
  90. /* Format_version=1, Width=16, Height=16, Depth=1, Valid_bits_per_item=16   6
  91.  */
  92. /*    0x8888,0x2222,0x8888,0x0000,0x8888,0x2222,0x8888,0x0000,
  93.     0x8888,0x2222,0x8888,0x0000,0x8888,0x2222,0x8888,0x0000
  94. */
  95. };
  96. mpr_static( w_s_80, 16, 16, 1, w_im_80 );
  97.  
  98. static short w_im_90[] = {
  99. /* Format_version=1, Width=16, Height=16, Depth=1, Valid_bits_per_item=16
  100.  */
  101.     0x8080,0x0000,0x0808,0x0000,0x8080,0x0000,0x0808,0x0000,
  102.     0x8080,0x0000,0x0808,0x0000,0x8080,0x0000,0x0808,0x0000
  103. };
  104. mpr_static( w_s_90, 16, 16, 1, w_im_90 );
  105.  
  106. static short w_im1_0[] = {        /* black */
  107. /* Format_version=1, Width=16, Height=16, Depth=1, Valid_bits_per_item=16
  108.  */
  109.     0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
  110.     0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000
  111. };
  112. mpr_static( w_s1_0, 16, 16, 1, w_im1_0 );
  113.  
  114. SHAR_EOF
  115. ############################
  116.  
  117. cat << \SHAR_EOF > src/siplmenu.c
  118. #include "ipl.x"
  119. siplmenu( proc )
  120. char proc[];
  121. {
  122. char p1[80], p2[80];
  123.  
  124. if( strcmp( proc, "Endoffile" )==0 ) while( 1 ) {
  125.     message( Controlfile,
  126.         "Press RETURN for next file,",
  127.         "enter another file to view,",
  128.         "or enter 'q' to quit." );
  129.     get_string_box( p2, "> ", 8.0, 9.5, 11.0, 9.8 );
  130.     if( strcmp( p2, "q" )==0 ) { gdp_exit(); }
  131.     else    {
  132.         message( "Next control file:", p2, "", "" );
  133.         if( ! restart( p2 ) ) { sleep( 3 ); continue; }
  134.         NTshow();
  135.         break;
  136.         }
  137.     }
  138.  
  139. if( strcmp( proc, "Pagebreak" )==0 ) {
  140.     message( "SIPL graphics previewer", "", "More..", "Press RETURN.." );
  141.     get_string_box( p2, "> ", 8.0, 9.5, 11.0, 9.8 );
  142.     }
  143. }
  144. SHAR_EOF
  145. ############################
  146.  
  147. cat << \SHAR_EOF > src/sunv.c
  148. /* sunview.c
  149. IPL sunview driver. (c) 1989 Steve Grubb.
  150.  
  151. Use compile option -DNOEVENTS if you do not need to handle mouse/keyboard events.
  152. Otherwise, you have to write a function handle_event( x, y, e ) that will get
  153. called whenever waiting for an event.  Arguments: x and y are double values indicating
  154. the position of the mouse at the time of the event, in your units;  e is the integer
  155. event identifier (see Sunview Pixwind guide), generally the ascii value of keys, and
  156. other values for mouse events.
  157.  
  158. User origin is lower-left.
  159.  
  160.  
  161. */
  162.  
  163. #include <stdio.h>
  164. #include <ctype.h>
  165. #include <sys/file.h>
  166. #include <suntool/sunview.h>  /* sun stuff */
  167. #include <suntool/canvas.h>  /* sun stuff */
  168. #include "shading.h"
  169. #define SUNV_FONT_PATH "/usr/lib/fonts/fixedwidthfonts"
  170. #define MAX_D_ROWS 1000
  171. #define AREA_WIDTH 900
  172. #define AREA_HEIGHT 900
  173.  
  174. #define WHITE 0
  175. #define BLACK 255
  176.  
  177. double xscale, yscale;
  178. double xsca_inv(), ysca_inv();
  179. double oldx, oldy;
  180.  
  181. int color, backcolor;
  182.  
  183. /* polygon vertexes */
  184. struct pr_pos vlist[MAX_D_ROWS];
  185. int nv = 0;
  186.  
  187. /* sunview variables.. */
  188. Frame w_fr;
  189. Canvas w_cvs;
  190. int w_width, w_height;
  191. struct rect w_rect; /* drawing area rect */
  192. struct pixwin *w_pw; /* window handle */
  193. Pixfont *w_font;  /* current font */
  194. int w_ppc;    /* pixels per character (across) for current font */
  195. Pr_brush w_br, *w_brush = &w_br ; /* line width */
  196. Pr_texture w_tex, *w_texture = &w_tex; /* line dash pattern */
  197.  
  198. static void SVevent();
  199. int w_waitflag = 0;
  200.  
  201. short w_dash[4][10][6]= {
  202.         { {1}, {1,1}, {3,1}, {5,1}, {2,1,1,1}, {4,1,1,1}, {6,1,1,1}, 
  203.           {2,1,1,1,1,1}, {4,1,1,1,1,1}, {6,1,1,1,1,1} },
  204.         { {2}, {2,2}, {6,2}, {10,2}, {4,2,2,2}, {8,2,2,2}, {12,2,2,2}, 
  205.           {4,2,2,2,2,2}, {8,2,2,2,2,2}, {12,2,2,2,2,2} },
  206.         { {3}, {3,3}, {9,3}, {15,3}, {6,3,3,3}, {12,3,3,3}, {18,3,3,3}, 
  207.           {6,3,3,3,3,3}, {12,3,3,3,3,3}, {18,3,3,3,3,3} },
  208.         { {4}, {4,4}, {12,4}, {20,4}, {8,4,4,4}, {16,4,4,4}, {24,4,4,4}, 
  209.           {8,4,4,4,4,4}, {16,4,4,4,4,4}, {24,4,4,4,4,4} }
  210.             };
  211. /* icon */
  212. static short ic_image[258] = {
  213. #include "ipl.icon"
  214. };
  215. mpr_static(gfxic_mpr, 64, 64, 1, ic_image);
  216.  
  217. static    struct icon icon = {64, 64, (struct pixrect *)NULL, 0, 0, 64, 64,
  218.         &gfxic_mpr, 0, 0, 0, 0, NULL, (struct pixfont *)NULL,
  219.         ICON_BKGRDCLR};
  220.  
  221.  
  222. /* =============================================== */
  223. /* SVsetup()-- initialize the window and parameters */
  224. SVsetup( x_max, y_max )
  225. double x_max, y_max;
  226. {
  227. w_fr = window_create( NULL, FRAME, 
  228.     WIN_HEIGHT, AREA_HEIGHT, WIN_WIDTH, AREA_WIDTH, WIN_X, 0, WIN_Y, 0, 
  229.     FRAME_LABEL, "sipl", FRAME_ICON, &icon, 0 );
  230. w_cvs = window_create( w_fr, CANVAS, WIN_EVENT_PROC, SVevent, 0 );
  231. window_set( w_cvs, WIN_CONSUME_KBD_EVENT, WIN_ASCII_EVENTS, 0 );
  232. w_pw = canvas_pixwin( w_cvs );
  233.  
  234. color = BLACK;
  235. backcolor = WHITE;
  236. w_height = AREA_HEIGHT - 20;    /* in pixels */
  237. w_width = AREA_WIDTH;        /* in pixels */
  238. xscale = (double)(w_width) / (x_max);
  239. yscale = (double)(w_height) / (y_max);
  240. w_texture->pattern = w_dash[0][0];
  241. w_brush->width = 1; 
  242. window_set( w_fr, WIN_SHOW, TRUE, 0 );
  243. (void) notify_dispatch();
  244. }
  245.  
  246. /* ====================== */
  247. static void SVevent( ecvs, e )
  248. Canvas ecvs;
  249. Event *e;
  250. {
  251. int x1, y1, eid;
  252.  
  253. #ifndef NOEVENT
  254. x1 = event_x( e );
  255. y1 = event_y( e );
  256. if( event_is_ascii(e) ) {
  257.     w_waitflag = handle_event( xsca_inv( x1 ), ysca_inv( y1 ), event_action( e ) );
  258.     }
  259. if( event_is_button(e) ) {
  260.     /* use generic button identifiers.. */
  261.     if( event_action(e)  == MS_LEFT ) eid = 1001;
  262.     if( event_action(e) == MS_MIDDLE ) eid = 1002;
  263.     if( event_action(e) == MS_RIGHT ) eid = 1003;
  264.     w_waitflag = handle_event( xsca_inv( x1 ), ysca_inv( y1 ), eid );
  265.     }
  266. #endif
  267. }
  268.  
  269. /* ====================== */
  270. SVwait()
  271. {
  272. w_waitflag = 0;
  273. #ifndef NOEVENT
  274. while( ! w_waitflag ) {
  275.     (void) notify_dispatch();
  276.     usleep( 10000 );  /* check notifier every .01 seconds */
  277.     }
  278. #endif
  279. }
  280.  
  281. /* ==================== scale in x to window size */
  282. xsca( f )
  283. double f;
  284. int iout;
  285. iout = (int) (f * xscale); 
  286. return( iout );
  287. }
  288.  
  289. /* ==================== inverse of xsca */
  290. double xsca_inv( i )
  291. int i;
  292. {
  293. double out;
  294. out = (double) i / xscale;
  295. return( out );
  296. }
  297.  
  298. /* ==================== scale in y to window size */
  299. ysca( f )
  300. double f;
  301. int iout;
  302. iout = w_height - (int) (f * yscale);
  303. return( iout );
  304. }
  305.  
  306. /* ===================== inverse of ysca */
  307. double ysca_inv( i )
  308. int i;
  309. {
  310. double out;
  311. out = (double)(w_height-i) / yscale;
  312. return( out );
  313. }
  314.  
  315. /* ==================== clear the display */
  316. SVclear()
  317. {
  318. pw_writebackground( w_pw, 0, 0, w_width, w_height, (PIX_SRC | PIX_COLOR(backcolor)) );
  319. }
  320.  
  321. /* ====================  line to */
  322. SVlineto(x,y)  
  323. double x, y;
  324. int a, b, c, d;
  325. a = xsca( oldx ); b = ysca( oldy ); c = xsca( x ); d = ysca( y );
  326. pw_line( w_pw, a, b, c, d, w_brush, w_texture, (PIX_SRC | PIX_COLOR(color)) );
  327. oldx=x;
  328. oldy=y;
  329. }
  330.  
  331. /* =====================  moveto */
  332. SVmoveto(x,y)   
  333. double x, y;
  334. {
  335. oldx = x;
  336. oldy = y;
  337. }
  338.  
  339. /* ===================== dot */
  340. SVdot(x,y)    
  341. double x, y;
  342. {
  343. pw_put( w_pw, xsca(x), ysca(y), color );
  344. }
  345.  
  346. /* ===================== read pixel value */
  347. SVread(x,y)   
  348. double x, y;
  349. {
  350. pw_get( w_pw, xsca(x), ysca(y) );
  351. }
  352.  
  353. /* ===================== set point size of type */
  354. /* SVpointsize */
  355. SVpointsize( p )
  356. int p;
  357. {
  358. char fontdir[60], buf[65];
  359. strcpy( fontdir, SUNV_FONT_PATH );
  360.  
  361. if( p <= 6 )         { p = 6; w_ppc = 4; }
  362. if( p == 7 || p == 8 )     { p = 7; w_ppc = 6; }
  363. if( p == 9 || p == 10 )    { p = 10; w_ppc = 7; }
  364. if( p == 11 )        { w_ppc = 7; }
  365. if( p == 12 || p == 13 ){ p = 12; w_ppc = 8; }
  366. if( p == 14 || p == 15 ){ p = 14; w_ppc = 9; }
  367. if( p == 16 || p == 17 ){ p = 16; w_ppc = 10; }
  368. if( p >= 18 && p <= 22 ){ p = 18; w_ppc = 11; }
  369. if( p > 22 ){ p = 24; w_ppc = 14; }
  370.  
  371. if( p < 10 ) sprintf( buf, "%s/screen.r.%d", fontdir, p );
  372. else if( p == 11 ) sprintf( buf, "%s/screen.r.%d", fontdir, p );
  373. else sprintf( buf, "%s/cour.b.%d", fontdir, p );
  374.  
  375. if( w_font != (Pixfont *) 0 ) pf_close( w_font );
  376. w_font = pf_open( buf );
  377. if( w_font == NULL ) { w_font = pw_pfsysopen(); }
  378. return( w_ppc );
  379. }
  380.  
  381. /* ==================== display left adjusted text starting at current position */
  382. SVtext( s, aw )
  383. char s[];
  384. double *aw; /* actual string width in inches (sent back) */
  385. {
  386. pw_ttext( w_pw, xsca(oldx), ysca(oldy), (PIX_SRC | PIX_COLOR(color)), w_font, s );
  387. oldx+= (double)((strlen(s)-1)* w_ppc ); 
  388. *aw = xsca_inv( (strlen(s)-1) * w_ppc );
  389. }
  390.  
  391. /* ==================== display centered text */
  392. SVcentext( s, w, x, aw )
  393. char s[];
  394. double w;
  395. double *x; /* actual X starting point in inches (sent back) */
  396. double *aw; /* actual string width in inches (sent back) */
  397. {
  398. double width;
  399.  
  400. strip_ws( s );
  401. width = xsca_inv( w_ppc*strlen( s ) );
  402. SVmoveto( oldx+((w-width)/2.0), oldy );
  403. SVtext( s, aw );
  404. *x = xsca_inv((int)( oldx+((w-width)/2.0) ) );
  405. }
  406.  
  407. /* ==================== display right-justified text */
  408. SVrightjust( s, w, x, aw )
  409. char s[];
  410. double w;
  411. double *x; /* actual X starting point in inches (sent back) */
  412. double *aw; /* actual string width in inches (sent back) */
  413. {
  414. double width;
  415.  
  416. strip_ws( s );
  417. width = xsca_inv( w_ppc*strlen( s ) );
  418. SVmoveto( oldx+(w-width), oldy );
  419. SVtext( s, aw );
  420. *x = xsca_inv((int)(oldx+(w-width) ));
  421. }
  422.  
  423. /* ==================== set the drawing color */
  424. SVcolor( d, b )
  425. int d, b;
  426. {
  427. color = d; backcolor = b;
  428. }
  429.  
  430.  
  431. /* ==================== add to "fill path" */
  432. SVpath( x, y )
  433. double x, y;
  434. {
  435. if( nv == 0 ) { vlist[0].x = xsca( oldx ); vlist[0].y = ysca( oldy ); nv++; }
  436. vlist[nv].x = xsca(x);
  437. vlist[nv].y = ysca(y);
  438. nv++;
  439. }
  440.  
  441. /* ==================== fill prev. defined polygon path with color c */
  442. SVshade( c )
  443. double c; 
  444. {
  445. int n[1];
  446. Pixrect *pr;
  447. if( c >= 0.0 && c <= 1.0 ) {
  448.     if( c == 1.0 ) pr = &w_s1_0;
  449.     else if( c > .95 ) pr = &w_s_90;
  450.     else if( c > .90 ) pr = &w_s_80;
  451.     else if( c > .85 ) pr = &w_s_70;
  452.     else if( c > .75 ) pr = &w_s_60;
  453.     else if( c > .65 ) pr = &w_s_50;
  454.     else if( c > .55 ) pr = &w_s_40;
  455.     else if( c > .45 ) pr = &w_s_30;
  456.     else if( c > .35 ) pr = &w_s_20;
  457.     else if( c > .15 ) pr = &w_s_10;
  458.     else if( c >= 0.0 ) pr = &w_s_00;
  459.     else pr = (Pixrect *) 0;
  460.     }
  461.  
  462. n[0] = nv;
  463. pw_polygon_2( w_pw, 0, 0, 1, n, vlist, (PIX_SRC | PIX_COLOR((int)(c))), pr, 0, 0 ); 
  464. nv = 0;
  465. }
  466.  
  467. /* ========= set line dotting attribs ============= */
  468.  
  469. SVlinetype( t, w, mag )
  470. char t[];
  471. double w, mag;
  472. {
  473. int i, j, k;
  474.  
  475. if( strlen( t ) < 1 ) return( 0 );
  476. if( mag < 1 ) mag = 1;
  477. if( mag > 4 ) mag = 4;
  478. w_brush->width = (int)((w*1.6)+0.5);
  479. w_texture->pattern = w_dash[ (int)mag-1 ][ atoi( t ) % 10 ];
  480. }
  481.  
  482. /* ========= batch calls for efficiency  ========== */
  483. SVbatch_on()
  484. {
  485. (void) notify_dispatch();
  486. pw_batch_on( w_pw );
  487. }
  488. SVbatch_off()
  489. {
  490. (void) notify_dispatch();
  491. pw_batch_off( w_pw );
  492. }
  493.  
  494.  
  495.  
  496. /* =========================================== */
  497. /* sets up color map, 0 = white, 255 = black, color mixes from 1 to 114 */
  498. setup_colormap()
  499. {
  500. u_char red[256], grn[256], blu[256];
  501. int i, j;
  502.  
  503. red[0] = (u_char) 0;                /* background color */
  504. grn[0] = (u_char) 0;
  505. blu[0] = (u_char) 0;
  506.  
  507.     for (i=0; i<19; i++) {
  508.         red[i +   1] = (u_char) ( 0.99 * 256 );        /* ramp to yellow */
  509.         grn[i +   1] = (u_char) ( 0.055*i * 256 );
  510.         blu[i +   1] = (u_char) ( 0.0 * 256 );
  511.  
  512.         red[i +  20] = (u_char) ( (0.99-0.055*i) * 256 );    /* ramp to green */
  513.         grn[i +  20] = (u_char) ( 0.99 * 256 );
  514.         blu[i +  20] = (u_char) ( 0.0 * 256 );
  515.  
  516.         red[i +  39] = (u_char) ( 0.0 * 256 );        /* ramp to turqouise */
  517.         grn[i +  39] = (u_char) ( 0.99 * 256 );
  518.         blu[i +  39] = (u_char) ( 0.055*i * 256 );
  519.  
  520.         red[i +  58] = (u_char) ( 0.0 * 256 );        /* ramp to blue */
  521.         grn[i +  58] = (u_char) ( ( 0.99-0.055*i ) * 256 );
  522.         blu[i +  58] = (u_char) ( 0.99 * 256 );
  523.  
  524.         red[i +  77] = (u_char) ( 0.055*i * 256 );        /* ramp to violet */
  525.         grn[i +  77] = (u_char) ( 0.0 * 256 );
  526.         blu[i +  77] = (u_char) ( 0.99 * 256 );
  527.  
  528.         red[i +  96] = (u_char) ( 0.99 * 256 );        /* ramp to red */
  529.         grn[i +  96] = (u_char) ( 0.0 * 256 );
  530.         blu[i +  96] = (u_char) ( (0.99-0.055*i) * 256 );
  531.         }
  532. for( i = 115, j = 0; i < 125; i++, j+= 25 ) red[i] = blu[i] = grn[i] = j;
  533. for( i = 125, j = 255; i < 256; i++ ) { j = abs(j-255); red[i] = blu[i] = grn[i] = j ; }
  534.  
  535.  
  536. pw_setcmsname( w_pw, "dots" );
  537. pw_putcolormap( w_pw, 0, 256, red, grn, blu );
  538. }
  539.  
  540.  
  541. SHAR_EOF
  542. ############################
  543.  
  544. cat << \SHAR_EOF > src/template.h
  545. char *Template[350] =  { "Proc Areadef:",
  546. "Area.bottom: 0 to 12    :   : Units are inches from lower left.",
  547. "Area.file: token    :   : file containing user defined areas",
  548. "Area.left: 0 to 12    :   :",
  549. "Area.rectangle: 2coordpair   :  : alternately, two coord-pairs (low left, up right) rectangle",
  550. "Area.right: 0 to 12    :   : | These four must all be used together.",
  551. "Area.top: 0 to 12    :   : ",
  552. "Area:  token    : standard : preset graphics area name (see area.coords)",
  553. "Clone:  token    :  : to inherit parms from a previous Areadef.",
  554. "Font:  font    :         : standard font to be used on axis labels etc.",
  555. "Frame:  {single,double,none}  : none  : frame of graphic area ",
  556. "Saveas:  token    :  : to give this Areadef a name so it can be Cloned later.",
  557. "Shade:  color    :   : shade of graphic area",
  558. "Subtitle.above: -12 to 12 (T)   : 0.02  : distance of 1st area title line above window top, inches",
  559. "Subtitle.font: font    :   : font for area title",
  560. "Subtitle.justify: {center,left,right}  : left  : title to be centered, left, or right justified",
  561. "Subtitle.size: charsize   : 10  : char size of title",
  562. "Subtitle: text    :   : area title",
  563. "Xaxis:  {bottom,top,both,none}  : bottom : where to draw X axis",
  564. "Xinc:  number    : 1  : increment.. put a tic mark every n units",
  565. "Xlabel.position: -12 to 12 (X)   : 0.6  : distance of x axis identifier from window bottom, inches",
  566. "Xlabel.size:  charsize   : 10  : char size for x axis identifier",
  567. "Xlabel:  text    :   : x axis identifier",
  568. "Xmax:  number     :   : maximum in x",
  569. "Xmin:  number     : 0   : minimum in x",
  570. "Xscaletype: {linear,log,yymm}   : linear : x scaling discipline",
  571. "Xstart.0or1: 0 to 10    : 0  : tell x stubs where to start ",
  572. "Xstub.fileline: number    : 0  : line in a stub text file to start at",
  573. "Xstub.grid: {line,shade,none,wline}  : none  : form a grid of lines or shaded blocks",
  574. "Xstub.minor: 0 to 100   : 0  : create this many divisions between regular tics",
  575. "Xstub.nolonetics: {y,n} : y : if y, no tics will be produced where there are no stubs",
  576. "Xstub.shade: color    : 0.98  : shade for the shaded blocks",
  577. "Xstub.size:  charsize   : 7  : char size for stubs",
  578. "Xstub.startmonth: 1 to 12   :   : for month stubs, leftmost month",
  579. "Xstub.startyear: 0 to 99   :   : for month stubs, leftmost year ",
  580. "Xstub.stubs: {bottom,top,both,none}  : bottom : produce labeled axis on left, right, or both sides",
  581. "Xstub.ticlen.minor: -2 to 2 (X)   : 0.035  : length of minor tics in inches (negative inverts it)",
  582. "Xstub.ticlen: -2 to 2 (X)   : 0.08  : length of major tics in inches (negative inverts it)",
  583. "Xstub.tics: {bottom,top,both,none}  : bottom : which side(s) to put tics on",
  584. "Xstub.yofs: -2 to 2 (X)   : 0.2  : distance of stubs up(-) or down(+) from x axis in inches",
  585. "Xstub:   text    : num  : stubs for tics (num, a file name, a var, or literal)",
  586. "Xticfmt: token    : %4.0f  : format for display of numbers in X (like printf)",
  587. "Yaxis:  {left,right,both,none}  : left  : where to draw Y axis",
  588. "Yinc:  number    : 1  : increment.. put a tic mark every n units",
  589. "Ylabel.position: -12 to 12 (Y)   : 0.6  : distance of y axis identifier from window left, inches",
  590. "Ylabel.size:  charsize   : 10   : char size for y axis identifier",
  591. "Ylabel:  text    :   : y axis identifier",
  592. "Ymax:  number    :   : maximum in y",
  593. "Ymin:  number    : 0  : minimum in y",
  594. "Yscaletype: {linear,log}   : linear : y scaling discipline",
  595. "Ystart.0or1: 0 to 10    : 0  : tell y stubs to start at 0 ",
  596. "Ystub.fileline: number    : 0  : line in a stub text file to start at",
  597. "Ystub.grid: {line,shade,none,wline}  : none  : form a grid of lines or shaded blocks",
  598. "Ystub.minor: 0 to 100   : 0  : create this many divisions between regular tics",
  599. "Ystub.nolonetics: {y,n} : y : if y, no tics will be produced where there are no stubs",
  600. "Ystub.shade: color     : 0.98  : shade for the shaded blocks",
  601. "Ystub.size:  charsize   : 7  : char size for stubs",
  602. "Ystub.stubs:  {left,right,both,none}  : left  : produce labeled axis on left, right, or both sides",
  603. "Ystub.ticlen.minor: -2 to 2 (Y)   : 0.035  : length of minor tics in inches (negative inverts it)",
  604. "Ystub.ticlen: -2 to 2 (Y)   : 0.08  : length of major tics in inches (negative inverts it)",
  605. "Ystub.tics: {left,right,both,none}  : left  : which side(s) to put tics on",
  606. "Ystub.xofs: -2 to 2 (Y)   : 0.1  : distance from y axis to right side of y stub",
  607. "Ystub:   text    : num   : stubs for tics (num, a file name, a var, or literal)",
  608. "Yticfmt: token    : %4.0f  : format for display of numbers in Y (like printf)",
  609. "Proc Arrow:",
  610. "Clone:  token    : :",
  611. "Points:  2coordpair   : : x1, y1, x2, y2.  Arrowhead will be at (x2, y2)",
  612. "Saveas:  token    : : ",
  613. "Proc Bargraph:",
  614. "Clone:  token  :  : to clone an earlier proc's set of parameters",
  615. "Field: dfield (list8) (M) :   : a field for each bar or subbar",
  616. "Format: {single,cluster,stack} : single : single bars, clusters of bars, or bars stacked up",
  617. "Idfield.position: -1 to 1 : 0.02  : distance of label above (or below) top of bar (inches)",
  618. "Idfield.size:  charsize : 6  : char size of labels",
  619. "Idfield: dfield (list8) :   : bars can be labeled using these field(s)",
  620. "Killwild: number  :   : if a data value greater than this is found, abort ",
  621. "Outlinebars: {y,n}  : y  : outline for each bar",
  622. "Saveas:  token  :  : to save a set of parms for cloning",
  623. "Segment: {y,n}  : n  : segment bars at axis tics",
  624. "Separation.sub: -2 to 2  : 0.03  : separation factor between sub-bars in a cluster",
  625. "Separation: -2 to 2  : 0.20  : separation factor between major bar spaces ",
  626. "Shade:   color (list8) : .2 .5 .8 1 0  : a shade for each bar or subbar",
  627. "Xfield:  dfield  :  : X position of bars can be determined by this data field *",
  628. "Xstart.0or1: {0,1}  : 1  : start bars at X=0 or X=1",
  629. "Zeroat:  number  :   : bars point down at values less than this (usually 0)",
  630. "Proc Boxplot:",
  631. "Clone:  token    :  : to clone an earlier proc's set of parameters",
  632. "Datarow: number     : 1  : the row in the data that contains the above 6 values",
  633. "Ends:  {y,n}    : y  : do little cross-bars on the ends?",
  634. "Fields:  dfield (list6) (M)  :   : the 6 data fields (see below)",
  635. "Label.size: charsize   : 7  : size of N label in points",
  636. "Linethick: 0 to 5    : 1  : thickness of boxplot line",
  637. "Printn:  {y,n}    : y  : print an N=... string at the bottom?",
  638. "Saveas:  token    :  : to save a set of parms for cloning",
  639. "Width:  number    : 0.5  : width of box, in data units",
  640. "Xloc:  number    : 0.5  : where box will be centered in x, in data units",
  641. "Proc Distribution:",
  642. "Axdist.length:  -2 to 2    : 0.08  : length of distribution bars ",
  643. "Axdist:  {y,n}    : n  : show bar distributions on axes",
  644. "Clone:  token    :  : to clone an earlier proc's set of parameters",
  645. "Cluster: {y,n}    : y  : offset overlaying points slightly to show duplicity",
  646. "Idfield: dfield    :  : case identifier may be in this field",
  647. "Mark.field: dfield     :   : if specified, mark is contents of this field",
  648. "Mark.font: font      :   : font for points",
  649. "Mark.size: charsize   : 6  : size (in point units) for data points",
  650. "Mark:  token    : sym6e  : symbol code (symNS) or character(s) for points",
  651. "Saveas:  token    :  : to save a set of parms for cloning",
  652. "Shadefield: dfield     :  : if specified, shade of point symbols controlled by field",
  653. "Shadescale: number    :  : factor for scaling data to acceptable shade range (0..1)",
  654. "Sizefield: dfield     :  : if specified, size of symbols controlled by field ",
  655. "Sizescale: number    : 1  : factor for scaling data to acceptable size (4..20)",
  656. "Xfield:  dfield (M)   :   : x data comes from this field ",
  657. "Yfield:  dfield    :   : y data field.  If Yfield ommitted, do a bar distr.",
  658. "Proc Draw:",
  659. "Clone:  token    :  : to clone an earlier proc's set of parameters",
  660. "Linethick: 0.1 to 10   : 1  : thickness of line",
  661. "Linetype.magnify: 0.1 to 10   : 1  : magnification of patterns",
  662. "Linetype: 0 to 8    : 0  : line dash pattern",
  663. "Points:  text (M) (C)   :  : coord pairs, 2 per line (move+draw) or 1 per line (draw)",
  664. "Saveas:  token    :  : to save a set of parms for cloning",
  665. "System:  {data,absolute}   : absolute : which coord system points are in",
  666. "Proc Errorbars:",
  667. "Clone:  token    :  : to clone an earlier proc's set of parameters",
  668. "Double:  {y,n}    : y  : display 2 times the error amount?",
  669. "Errfield: dfield (M)   :  : field containing error amount in y",
  670. "Linethick: 0 to 10    : 0.3  : line thickness for error bars",
  671. "Offset:  -1 to 1    : 0  : amount of offset in X, in inches",
  672. "Saveas:  token    :  : to save a set of parms for cloning",
  673. "Taillen: 0 to 1    : 0.04  : width of tails at the end of the bars",
  674. "Xfield:  dfield (M)   :  : field containing point x location",
  675. "Yfield:  dfield (M)   :  : field containing point y location",
  676. "Proc Getdata:",
  677. "Append:  {y,n}    : n  : if y, new data will be put below existing data",
  678. "Clone:  token    :  : to clone an earlier proc's set of parameters",
  679. "Data:  text    :  : following lines contain data",
  680. "Datafile: token (M)     :   : file name, '-' (terminal), or a Unix command ",
  681. "Join:  {y,n}    : n  : if y, new data will be put beside existing data",
  682. "Percents: dfield (list20)   :  : change these fields from N to percentages, based on total",
  683. "Saveas:  token    :  : to save a set of parms for cloning",
  684. "Selectfields: token (list20)   : all  : select only these fields from input",
  685. "Startline: number    : 1  : line to start with (first line is line 1)",
  686. "Stopline: number     : 9999  : stop reading after this line is read",
  687. "Proc Legend:",
  688. "Backshade: color     :   : shade for backing box",
  689. "Clone:  token    :  : to clone an earlier proc's set of parameters",
  690. "Corner:  {A,B,C,D}   : A  : which corner of the area, clockwise from upperleft",
  691. "Entry.font: font    :   : font for legend entries",
  692. "Entry.size: charsize   : 7  : char size for legend entries",
  693. "Entry:  text (M)   :   : text for legend entries, one per line ",
  694. "Linethick: number (list10)  : 1 1 1 1 1 1 1 1 1 1   : thickness of line(s)",
  695. "Linetype.magnify: number (list10)  : 3 3 3 3 3 3 3 3 3 3   : mag. factor for dash pattern",
  696. "Linetype: number (list10)   :   : line dash type for (each) line",
  697. "Location.system: {absolute,data}  : absolute : coord system for the above",
  698. "Location: coordpair   :  : location for upperleft of legend",
  699. "Mark.font: font    :   : ",
  700. "Mark.size: charsize   : 7  :",
  701. "Mark:  list    :  : list of marks for legend entries (symNS or chars)",
  702. "Outlinebars: {y,n}    : n  : ' '",
  703. "Saveas:  token    :  : to save a set of parms for cloning",
  704. "Shade:  color (list10)   :  : for bar graphs",
  705. "Title.size: charsize   : 10  : size for legend title",
  706. "Title:  text    :  : legend title",
  707. "Proc Lineplot:",
  708. "Accum:  {y,n}    : n  : option to accumulate yalues of y",
  709. "Clone:  token    :  : to clone an earlier proc's set of parameters",
  710. "Label.size: charsize   : 8  : char size for line identifier",
  711. "Label:   text    :   : curve identifier, one per line",
  712. "Linethick: 0 to 10 (list8)  : 1 1 1 1 1 1 1 1  : thickness of line(s)",
  713. "Linetype.magnify: 0 to 10 (list8) : 3 3 3 3 3 3 3 3  : mag. factor for dash pattern",
  714. "Linetype: 0 to 8 (list8)  : 0 1 2 3 4 5 6 7 : line dash type for (each) line",
  715. "Mark.size: charsize   : 7  : Size for mark chars",
  716. "Mark:  list    :   : Mark char for points, one per line",
  717. "Numberfinal: {y,n}    : n  : display y value of rightmost point",
  718. "Numbers.offset: -1 to 1    : 0.015  : abs distance of numbers (+) above or (-)below line",
  719. "Numbers: {y,n}    : n  : display y value at each point",
  720. "Saveas:  token    :  : to save a set of parms for cloning",
  721. "Shade:  color (list8)   :               : shading below lines",
  722. "Stairstep.bars: {y,n}    : n  : for superimposing line over bar graph (moves it 1/2)",
  723. "Stairstep: {y,n}    : n  : lines form steps rather than diagonals",
  724. "Xfield:  dfield    :   : line's x data field (optional)",
  725. "Xstart.0or1: {0,1}    : 0  : if no x data field specified, start on or beside origin",
  726. "Yfield:  dfield (list8) (M)  :   : list of y fields for each line ",
  727. "Zeroat:  number    : 0  : point for zero crossing with shading ",
  728. "Proc Map:",
  729. "Clone:  token    :  : to clone an earlier proc's set of parameters",
  730. "Country.linethick: 0.1 to 5   : 1  : thickness for country boundary lines",
  731. "Country: {usa,usa+canada}  : usa+canada : map format",
  732. "List:  {y,n}    : y  : list state distribution down right side",
  733. "Mode:  {country,state,statedist} : state  : country outln, state outln, or state distribution",
  734. "Saveas:  token    :  : to save a set of parms for cloning",
  735. "Shade:  color (list10)   : 1 .9 .8 .6 .4 .2 : shades corresponding to the above thresholds",
  736. "State.linethick: 0.1 to 5   : 0.2  : thickness for state boundary lines",
  737. "Statefield: dfield    :  : field in which standard state/province name can be found",
  738. "Threshold: number (list10)   :  : thresholds for shading (don't include 0 or max)",
  739. "Valfield: dfield    :  : field in which n value can be found",
  740. "Proc Nicetab:",
  741. "Area.rectangle: 2coordpair   :  : two coord pairs (low left, up right) defining area",
  742. "Area:  token    :nicetab : a pre-defined area name, see area.coords",
  743. "Body.font: font    :  : body font",
  744. "Body.only: {y,n}    : n  : indicates no title present, process all as table body.",
  745. "Body.size: token    : 8  : body char size",
  746. "Clone:  token    :  : to clone an earlier proc's set of parameters",
  747. "File:  token (M)   :   : file containing ascii table",
  748. "Saveas:  token    :  : to save a set of parms for cloning",
  749. "Title.font: font    :   : title font",
  750. "Title.size: charsize   : 11  : title char size",
  751. "Proc Page:",
  752. "Clone:  token    :  : to clone an earlier proc's set of parameters",
  753. "Paperway: {portrait,landscape,screen} : portrait : the way paper will be held to look at",
  754. "Saveas:  token    :  : to save a set of parms for cloning",
  755. "Standard.font:  font    : /Helvetica : default font for everything on page",
  756. "Standard.linethick: 0 to 6   : 1  : standard line thickness",
  757. "Title.belowtop: -12 to 12 (T)   : 0.2  : distance of 1st title line below top of page",
  758. "Title.file: token    :  : file containing title",
  759. "Title.font: font    :   : font for page title",
  760. "Title.size: charsize   : 12  : char size of title",
  761. "Title:  text    :   : window title",
  762. "Proc Pagebreak:",
  763. "Clone: token : : this is not really useful, but all procs must have this",
  764. "Saveas: token : : this is not really useful, but all procs must have this",
  765. "Proc Pie:",
  766. "Field: dfield (M) : : Data field to use.  Numbers should be integer percentages.",
  767. "Center: coordpair : 4.0 5.5 : Location of center, in absolute units." ,
  768. "Radius: 0 to 5 :  3 : Radius of pie, in absolute units.",
  769. "Shade: color list20 : : Shades of pie sections",
  770. "Linethick: 0 to 10 : 1 : Thickness of lines",
  771. "Explode: 0 to 3 : 0.1 : Distance in abs units to 'explode' each piece",
  772. "Rotate: 0 to 360 : 0 : Rotate entire pie this many degrees counterclockwise",
  773. "Clone: token : :",
  774. "Saveas: token : :",
  775. "Proc Point:",
  776. "Clone:  token  :  : ",
  777. "Mark:  token  : sym6e  : symbol code (see example point1.g)",
  778. "Position: text (M) (C)  :  : position in absolute data system",
  779. "Saveas:  token  :  : ",
  780. "Size:  1 to 20  : 5  : marker size",
  781. "Proc Polygon:",
  782. "Clone:  token    :  : to clone an earlier proc's set of parameters",
  783. "Linethick: 0.1 to 10   : 1  : thickness of line for outline",
  784. "Linetype.magnify: 0.1 to 10   : 1  : magnification of patterns for outline",
  785. "Linetype: 0 to 8    : 0  : line dash pattern for outline",
  786. "Outline: {y,n}    : n  : outline polygon with a line?",
  787. "Points:  text (M) (C)   :  : one coord pair per line (points making up a polygon)",
  788. "Rectangle: 2coordpair   :  : (lower left and upper right) for a rectangle, abs units ",
  789. "Saveas:  token    :  : to save a set of parms for cloning",
  790. "Shade:  color    : 0.5  : shade of polygon",
  791. "System:  {data,absolute}   : absolute : which coord system points are in",
  792. "Proc QuitAppend:",
  793. "Clone:  token  :  : ",
  794. "Saveas:  token  :  : ",
  795. "Proc Rangebar:",
  796. "Clone:  token    :  : to clone an earlier proc's set of parameters",
  797. "Ends:  {y,n}    : y  : do little cross-bars on the ends?",
  798. "Field:  dfield (list5) (M)  :   : data fields (should have Nval members)",
  799. "Idfield: dfield    :   : data field holding id label",
  800. "Label.position: number    : 1  : position for N=.. label in Y data units",
  801. "Label.size: charsize   : 6  : size of the above label in points",
  802. "Linethick: 0 to 5    : 1  : thickness of boxplot line",
  803. "Midlineright:  {y,n}    : n  : option for making median lines protrude right only",
  804. "Midlinewidth: number    : 0  : size of median line in user units, 0 uses Width value",
  805. "Nval:  1 to 5    : 5  : number of values making up the box",
  806. "Saveas:  token    :  : to save a set of parms for cloning",
  807. "Shade:  color    : 1.0  : shade for inside of bar",
  808. "Width:  number    : 0.3  : width of box, in data units",
  809. "Xfield:  dfield    :   : (optional) data field, bar x placement",
  810. "Proc Text:",
  811. "Clone:  token    :  : to clone an earlier proc's set of parameters",
  812. "Direction: 0 to 359   : 0   : direction of text in degrees counterclockwise",
  813. "File:  token    :  : file containing text",
  814. "Embeddedcoords: {y,n} :  n : if y look for x and y values at beginning of each line",
  815. "Font:  font    :   : font to use",
  816. "Position: coordpair (M)   :   : location of beginning of 1st text line",
  817. "Saveas:  token    :  : to save a set of parms for cloning",
  818. "Size:  charsize   : 10  : size of text",
  819. "System:  {data,absolute}   : absolute : which coord system position is in",
  820. "Text:  text    :  : the text itself",
  821. "Proc Vbargraph:",
  822. "Clone:  token    :  : to clone an earlier proc's set of parameters",
  823. "Field:  dfield (list8)   :   : a field for each bar and subbar",
  824. "Format:  {single,cluster,stack}  : single : single bars, clusters of bars, or bars stacked up",
  825. "Idfield.position: -1 to 1   : 0.02  : distance of label above (or below) top of bar (inches)",
  826. "Idfield.size:  charsize   : 6  : char size of labels",
  827. "Idfield: dfield (list8)   :   : bars can be labeled using these field(s)",
  828. "Killwild: number    :   : if a data value greater than this is found, abort ",
  829. "Outlinebars: {y,n}    : y  : outline for each bar",
  830. "Saveas:  token    :  : to save a set of parms for cloning",
  831. "Segment: {y,n}    : n  : segment bars at axis tics",
  832. "Separation.sub: 0 to 1    : 0.03  : distance between sub-bars in cluster",
  833. "Separation: 0 to 1    : 0.20  : distance between major bar spaces",
  834. "Shade:   color (list8)   : .2 .5 .8 1 0  : a shade for each bar and subbar",
  835. "Yfield:  dfield    :  : Y position of bars (optional)",
  836. "Ystart.0or1: {0,1}    : 1  : start bars at Y=0 or Y=1",
  837. "Zeroat:  number    :   : bars point down at values less than this (usually 0)",
  838. "Proc Vector:",
  839. "Point1fields: dfield (list2) (M) : :fields in data holding x and y describing point p1 (x,y)",
  840. "Point2fields: dfield (list2) (M) : :fields in data holding x and y describing point p2 (x,y)",
  841. "Headlength: 0 to 2 : 0.2 :determines size of arrowhead, length in inches from point",
  842. "Headwidth:  0 to 0.8 : 0.24 :determines size of arrowhead, arc of half of arrow in radians",
  843. "Headshade: color : 0.0 :color of arrowhead",
  844. "Saveas: token    : : to save a set of parms for cloning",
  845. "Clone:    token    : : to clone an earlier proc's set of parameters",
  846. "Proc Vrangebar:",
  847. "Clone:    token :    : to clone an earlier proc's set of parameters",
  848. "Ends:    {y,n} : y : do little cross-bars on the ends?",
  849. "Field:    dfield (list5) (M) : : data fields (should have Nval members)",
  850. "Idfield: dfield    : : data field holding id label",
  851. "Label.size: charsize : 6 : size of the above label in points",
  852. "Label.position: number    : 1 : position for N=.. label in Y data units",
  853. "Linethick: 0 to 5 : 1 : thickness of boxplot line",
  854. "Midlinewidth: number : 0 : size of median line in user units, 0 uses Width value",
  855. "Midlineright: {y,n} : n    : option for making median lines protrude right only",
  856. "Nval: 1 to 5    : 5 : number of values making up the box",
  857. "Saveas:    token    : : to save a set of parms for cloning",
  858. "Shade: color    : 1.0 : shade for inside of bar",
  859. "Width: number    : 0.3 : width of box, in data units",
  860. "Yfield:    dfield    : : (optional) data field, bar x placement",
  861. "", "", "" } ;
  862.  
  863. /* number of lines per proc */
  864. int Tdx[30] = { 0, 
  865.         64,  /* Areadef */
  866.         4,   /* Arrow */
  867.         17,  /* Barg */
  868.         11,  /* Boxp */
  869.         17,  /* Dist */
  870.         8,   /* Draw */ 
  871.         10,  /* Errorbars */
  872.         11,  /* Getdata */
  873.         20,  /* Legend */ 
  874.         21,  /* Linep */
  875.         12,  /*  Map */
  876.         11,  /* Nicetab */
  877.         11,  /* Page */
  878.         3,   /* Pagebreak */
  879.         10,   /* Pie */
  880.         6,   /* Point */
  881.         11,  /* Polygon */
  882.         3,   /* QuitAppend */
  883.         15,  /* Rangebar */
  884.         11,  /* Text */
  885.         17,  /* Vbar */
  886.         8,   /* Vector */
  887.         15,  /* Vrangebar */
  888.         0, 0, 0, 0 };  
  889.  
  890. /* Note, only one space allowed after word "Proc" */
  891. SHAR_EOF
  892. ############################
  893.  
  894. cat << \SHAR_EOF > src/text.c
  895. #include "ipl.x"
  896. #define DATA 0
  897. #define ABSOLUTE 1
  898.  
  899. Text( )
  900. {
  901. int sys, ln, embedded, p, ix;
  902. double x, y, theta, size;
  903. char s1[40], s2[40];
  904. FILE *fp;
  905.  
  906. gget( Buf, "System" );
  907. if( Buf[0] == 'd' ) { 
  908.     sys = DATA; 
  909.     if( DXlo == 0 && DXhi == 0 ) { fprintf( stderr, "No graphics area.\n" ); gdp_exit(); }
  910.     }
  911. else sys = ABSOLUTE;
  912.  
  913. gget( Buf, "Font" ); NTfont( Buf );
  914. gget( Buf, "Size" ); size = atof( Buf ); NTptsize( size );
  915. gget( Buf, "Position" ); 
  916. sscanf( Buf, "%lf %lf", &x, &y );
  917. gget( Buf, "Direction" ); theta = atof( Buf );
  918.  
  919. if( theta != 0 ) NTchardir( theta );
  920.  
  921. gget( Buf, "Embeddedcoords" );
  922. if( Buf[0] == 'y' ) embedded = 1; else embedded = 0;
  923.  
  924. gget( Buf, "File" );
  925. if( strlen( Buf ) > 0 ) fp = fopen( Buf, "r" );        /* text in a file */
  926. else     {        /* text given-- put it in a file */
  927.     gget( Buf, "Text" );
  928.     text_tofile( Buf, Tempfile );
  929.     fp = fopen( Tempfile, "r" );
  930.     }
  931. if( fp == NULL ) { fprintf( stderr, "Cant open text file" );  gdp_exit(); }
  932.  
  933. /* read the file and print the text */
  934. if( !embedded ) {
  935.     if( sys == DATA ) NTm( x, y );
  936.     else NTmov( x, y );
  937.     }
  938.  
  939. ln = 1;
  940. while( fgets( Buf, 200, fp ) != NULL ) {
  941.     if( embedded ) {
  942.         ix = 0;
  943.         strcpy( s1, getok( Buf, &ix ) );
  944.         strcpy( s2, getok( Buf, &ix ) );
  945.         if( goodnum( s1, &p ) && goodnum( s2, &p ) ) {
  946.             x = atof( s1 ); y = atof( s2 );
  947.             if( sys == DATA ) NTm( x, y );
  948.             else NTmov( x, y );
  949.             strcpy( Buf, &Buf[ix] );
  950.             strip_ws( Buf );
  951.             }
  952.         }
  953.     NTtext( Buf );
  954.     if( sys == DATA ) NTmov( da_x(x), da_y(y)-(ln*Chh) ); 
  955.     else NTmov( x, y-(ln*Chh) );
  956.     ln++;
  957.     }
  958.  
  959. fclose( fp );
  960. NTchardir( 0 );
  961. }
  962. SHAR_EOF
  963. ############################
  964.  
  965.  
  966.