home *** CD-ROM | disk | FTP | other *** search
- Subject: v21i041: 2D graphic system with table beautifier, Part10/14
- Newsgroups: comp.sources.unix
- Approved: rsalz@uunet.UU.NET
- X-Checksum-Snefru: 3c92451a cf1911e5 4faeb657 5c05c1a5
-
- Submitted-by: Steve Grubb <uunet!lsr-vax!scg>
- Posting-number: Volume 21, Issue 41
- Archive-name: ipl/part10
-
- # ipl part10
- # This is a shell archive.
- # Remove everything above and including the cut line.
- # Then run the rest of the file through sh.
- #---------------------- cut here -----------------------------
- #!/bin/sh
- # shar: Shell Archiver
- # Run the following text with /bin/sh to create:
- # src/shading.h
- # src/siplmenu.c
- # src/sunv.c
- # src/template.h
- # src/text.c
- cat << \SHAR_EOF > src/shading.h
-
- /* shading .... */
- static short w_im_00[] = { /* black */
- #include <images/square_black.pr>
- };
- mpr_static( w_s_00, 16, 16, 1, w_im_00 );
-
- static short w_im_10[] = {
- /* Format_version=1, Width=16, Height=16, Depth=1, Valid_bits_per_item=16
- */
- 0x7F7F,0xFFFF,0xF7F7,0xFFFF,0x7F7F,0xFFFF,0xF7F7,0xFFFF,
- 0x7F7F,0xFFFF,0xF7F7,0xFFFF,0x7F7F,0xFFFF,0xF7F7,0xFFFF
- };
- mpr_static( w_s_10, 16, 16, 1, w_im_10 );
-
-
- static short w_im_20[] = {
- /* Format_version=1, Width=16, Height=16, Depth=1, Valid_bits_per_item=16
- */
- 0x7777,0xFFFF,0x7777,0xFFFF,0x7777,0xFFFF,0x7777,0xFFFF,
- 0x7777,0xFFFF,0x7777,0xFFFF,0x7777,0xFFFF,0x7777,0xFFFF
- };
- mpr_static( w_s_20, 16, 16, 1, w_im_20 );
-
- static short w_im_30[] = {
- /* Format_version=1, Width=16, Height=16, Depth=1, Valid_bits_per_item=16
- */
- 0x7DF7,0xDF7D,0xFBEF,0xEFBE,0xBEFB,0xF7DF,0x7DF7,0xDF7D,
- 0xFBEF,0xEFBE,0xBEFB,0xF7DF,0x7DF7,0xDF7D,0xFBEF,0xEFBE
- } ;
- mpr_static( w_s_30, 16, 16, 1, w_im_30 );
-
- static short w_im_40[] = {
- /* Format_version=1, Width=16, Height=16, Depth=1, Valid_bits_per_item=16
- */
- 0x7777,0xDDDD,0x7777,0xDDDD,0x7777,0xDDDD,0x7777,0xDDDD,
- 0x7777,0xDDDD,0x7777,0xDDDD,0x7777,0xDDDD,0x7777,0xDDDD
- } ;
- mpr_static( w_s_40, 16, 16, 1, w_im_40 );
-
- static short w_im_50[] = {
- /* Format_version=1, Width=16, Height=16, Depth=1, Valid_bits_per_item=16
- */
- 0xEEEE,0xAAAA,0xAAAA,0xBBBB,0xEEEE,0xAAAA,0xAAAA,0xBBBB,
- 0xEEEE,0xAAAA,0xAAAA,0xBBBB,0xEEEE,0xAAAA,0xAAAA,0xBBBB
- };
- mpr_static( w_s_50, 16, 16, 1, w_im_50 );
-
- static short w_im_60[] = {
- /* Format_version=1, Width=16, Height=16, Depth=1, Valid_bits_per_item=16
- */
- 0x5555,0x5555,0x5555,0x5555,0x5555,0x5555,0x5555,0x5555,
- 0x5555,0x5555,0x5555,0x5555,0x5555,0x5555,0x5555,0x5555
- };
- mpr_static( w_s_60, 16, 16, 1, w_im_60 );
-
- static short w_im_70[] = {
- /* Format_version=1, Width=16, Height=16, Depth=1, Valid_bits_per_item=16
- */
- 0x8888,0x2222,0x8888,0x2222,0x8888,0x2222,0x8888,0x2222,
- 0x8888,0x2222,0x8888,0x2222,0x8888,0x2222,0x8888,0x2222
- };
- mpr_static( w_s_70, 16, 16, 1, w_im_70 );
-
- static short w_im_80[] = {
- #include <images/square_17.pr>
- /* Format_version=1, Width=16, Height=16, Depth=1, Valid_bits_per_item=16 6
- */
- /* 0x8888,0x2222,0x8888,0x0000,0x8888,0x2222,0x8888,0x0000,
- 0x8888,0x2222,0x8888,0x0000,0x8888,0x2222,0x8888,0x0000
- */
- };
- mpr_static( w_s_80, 16, 16, 1, w_im_80 );
-
- static short w_im_90[] = {
- /* Format_version=1, Width=16, Height=16, Depth=1, Valid_bits_per_item=16
- */
- 0x8080,0x0000,0x0808,0x0000,0x8080,0x0000,0x0808,0x0000,
- 0x8080,0x0000,0x0808,0x0000,0x8080,0x0000,0x0808,0x0000
- };
- mpr_static( w_s_90, 16, 16, 1, w_im_90 );
-
- static short w_im1_0[] = { /* black */
- /* Format_version=1, Width=16, Height=16, Depth=1, Valid_bits_per_item=16
- */
- 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
- 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000
- };
- mpr_static( w_s1_0, 16, 16, 1, w_im1_0 );
-
- SHAR_EOF
- ############################
-
- cat << \SHAR_EOF > src/siplmenu.c
- #include "ipl.x"
- siplmenu( proc )
- char proc[];
- {
- char p1[80], p2[80];
-
- if( strcmp( proc, "Endoffile" )==0 ) while( 1 ) {
- message( Controlfile,
- "Press RETURN for next file,",
- "enter another file to view,",
- "or enter 'q' to quit." );
- get_string_box( p2, "> ", 8.0, 9.5, 11.0, 9.8 );
- if( strcmp( p2, "q" )==0 ) { gdp_exit(); }
- else {
- message( "Next control file:", p2, "", "" );
- if( ! restart( p2 ) ) { sleep( 3 ); continue; }
- NTshow();
- break;
- }
- }
-
- if( strcmp( proc, "Pagebreak" )==0 ) {
- message( "SIPL graphics previewer", "", "More..", "Press RETURN.." );
- get_string_box( p2, "> ", 8.0, 9.5, 11.0, 9.8 );
- }
- }
- SHAR_EOF
- ############################
-
- cat << \SHAR_EOF > src/sunv.c
- /* sunview.c
- IPL sunview driver. (c) 1989 Steve Grubb.
-
- Use compile option -DNOEVENTS if you do not need to handle mouse/keyboard events.
- Otherwise, you have to write a function handle_event( x, y, e ) that will get
- called whenever waiting for an event. Arguments: x and y are double values indicating
- the position of the mouse at the time of the event, in your units; e is the integer
- event identifier (see Sunview Pixwind guide), generally the ascii value of keys, and
- other values for mouse events.
-
- User origin is lower-left.
-
-
- */
-
- #include <stdio.h>
- #include <ctype.h>
- #include <sys/file.h>
- #include <suntool/sunview.h> /* sun stuff */
- #include <suntool/canvas.h> /* sun stuff */
- #include "shading.h"
- #define SUNV_FONT_PATH "/usr/lib/fonts/fixedwidthfonts"
- #define MAX_D_ROWS 1000
- #define AREA_WIDTH 900
- #define AREA_HEIGHT 900
-
- #define WHITE 0
- #define BLACK 255
-
- double xscale, yscale;
- double xsca_inv(), ysca_inv();
- double oldx, oldy;
-
- int color, backcolor;
-
- /* polygon vertexes */
- struct pr_pos vlist[MAX_D_ROWS];
- int nv = 0;
-
- /* sunview variables.. */
- Frame w_fr;
- Canvas w_cvs;
- int w_width, w_height;
- struct rect w_rect; /* drawing area rect */
- struct pixwin *w_pw; /* window handle */
- Pixfont *w_font; /* current font */
- int w_ppc; /* pixels per character (across) for current font */
- Pr_brush w_br, *w_brush = &w_br ; /* line width */
- Pr_texture w_tex, *w_texture = &w_tex; /* line dash pattern */
-
- static void SVevent();
- int w_waitflag = 0;
-
- short w_dash[4][10][6]= {
- { {1}, {1,1}, {3,1}, {5,1}, {2,1,1,1}, {4,1,1,1}, {6,1,1,1},
- {2,1,1,1,1,1}, {4,1,1,1,1,1}, {6,1,1,1,1,1} },
- { {2}, {2,2}, {6,2}, {10,2}, {4,2,2,2}, {8,2,2,2}, {12,2,2,2},
- {4,2,2,2,2,2}, {8,2,2,2,2,2}, {12,2,2,2,2,2} },
- { {3}, {3,3}, {9,3}, {15,3}, {6,3,3,3}, {12,3,3,3}, {18,3,3,3},
- {6,3,3,3,3,3}, {12,3,3,3,3,3}, {18,3,3,3,3,3} },
- { {4}, {4,4}, {12,4}, {20,4}, {8,4,4,4}, {16,4,4,4}, {24,4,4,4},
- {8,4,4,4,4,4}, {16,4,4,4,4,4}, {24,4,4,4,4,4} }
- };
- /* icon */
- static short ic_image[258] = {
- #include "ipl.icon"
- };
- mpr_static(gfxic_mpr, 64, 64, 1, ic_image);
-
- static struct icon icon = {64, 64, (struct pixrect *)NULL, 0, 0, 64, 64,
- &gfxic_mpr, 0, 0, 0, 0, NULL, (struct pixfont *)NULL,
- ICON_BKGRDCLR};
-
-
- /* =============================================== */
- /* SVsetup()-- initialize the window and parameters */
- SVsetup( x_max, y_max )
- double x_max, y_max;
- {
- w_fr = window_create( NULL, FRAME,
- WIN_HEIGHT, AREA_HEIGHT, WIN_WIDTH, AREA_WIDTH, WIN_X, 0, WIN_Y, 0,
- FRAME_LABEL, "sipl", FRAME_ICON, &icon, 0 );
- w_cvs = window_create( w_fr, CANVAS, WIN_EVENT_PROC, SVevent, 0 );
- window_set( w_cvs, WIN_CONSUME_KBD_EVENT, WIN_ASCII_EVENTS, 0 );
- w_pw = canvas_pixwin( w_cvs );
-
- color = BLACK;
- backcolor = WHITE;
- w_height = AREA_HEIGHT - 20; /* in pixels */
- w_width = AREA_WIDTH; /* in pixels */
- xscale = (double)(w_width) / (x_max);
- yscale = (double)(w_height) / (y_max);
- w_texture->pattern = w_dash[0][0];
- w_brush->width = 1;
- window_set( w_fr, WIN_SHOW, TRUE, 0 );
- (void) notify_dispatch();
- }
-
- /* ====================== */
- static void SVevent( ecvs, e )
- Canvas ecvs;
- Event *e;
- {
- int x1, y1, eid;
-
- #ifndef NOEVENT
- x1 = event_x( e );
- y1 = event_y( e );
- if( event_is_ascii(e) ) {
- w_waitflag = handle_event( xsca_inv( x1 ), ysca_inv( y1 ), event_action( e ) );
- }
- if( event_is_button(e) ) {
- /* use generic button identifiers.. */
- if( event_action(e) == MS_LEFT ) eid = 1001;
- if( event_action(e) == MS_MIDDLE ) eid = 1002;
- if( event_action(e) == MS_RIGHT ) eid = 1003;
- w_waitflag = handle_event( xsca_inv( x1 ), ysca_inv( y1 ), eid );
- }
- #endif
- }
-
- /* ====================== */
- SVwait()
- {
- w_waitflag = 0;
- #ifndef NOEVENT
- while( ! w_waitflag ) {
- (void) notify_dispatch();
- usleep( 10000 ); /* check notifier every .01 seconds */
- }
- #endif
- }
-
- /* ==================== scale in x to window size */
- xsca( f )
- double f;
- {
- int iout;
- iout = (int) (f * xscale);
- return( iout );
- }
-
- /* ==================== inverse of xsca */
- double xsca_inv( i )
- int i;
- {
- double out;
- out = (double) i / xscale;
- return( out );
- }
-
- /* ==================== scale in y to window size */
- ysca( f )
- double f;
- {
- int iout;
- iout = w_height - (int) (f * yscale);
- return( iout );
- }
-
- /* ===================== inverse of ysca */
- double ysca_inv( i )
- int i;
- {
- double out;
- out = (double)(w_height-i) / yscale;
- return( out );
- }
-
- /* ==================== clear the display */
- SVclear()
- {
- pw_writebackground( w_pw, 0, 0, w_width, w_height, (PIX_SRC | PIX_COLOR(backcolor)) );
- }
-
- /* ==================== line to */
- SVlineto(x,y)
- double x, y;
- {
- int a, b, c, d;
- a = xsca( oldx ); b = ysca( oldy ); c = xsca( x ); d = ysca( y );
- pw_line( w_pw, a, b, c, d, w_brush, w_texture, (PIX_SRC | PIX_COLOR(color)) );
- oldx=x;
- oldy=y;
- }
-
- /* ===================== moveto */
- SVmoveto(x,y)
- double x, y;
- {
- oldx = x;
- oldy = y;
- }
-
- /* ===================== dot */
- SVdot(x,y)
- double x, y;
- {
- pw_put( w_pw, xsca(x), ysca(y), color );
- }
-
- /* ===================== read pixel value */
- SVread(x,y)
- double x, y;
- {
- pw_get( w_pw, xsca(x), ysca(y) );
- }
-
- /* ===================== set point size of type */
- /* SVpointsize */
- SVpointsize( p )
- int p;
- {
- char fontdir[60], buf[65];
- strcpy( fontdir, SUNV_FONT_PATH );
-
- if( p <= 6 ) { p = 6; w_ppc = 4; }
- if( p == 7 || p == 8 ) { p = 7; w_ppc = 6; }
- if( p == 9 || p == 10 ) { p = 10; w_ppc = 7; }
- if( p == 11 ) { w_ppc = 7; }
- if( p == 12 || p == 13 ){ p = 12; w_ppc = 8; }
- if( p == 14 || p == 15 ){ p = 14; w_ppc = 9; }
- if( p == 16 || p == 17 ){ p = 16; w_ppc = 10; }
- if( p >= 18 && p <= 22 ){ p = 18; w_ppc = 11; }
- if( p > 22 ){ p = 24; w_ppc = 14; }
-
- if( p < 10 ) sprintf( buf, "%s/screen.r.%d", fontdir, p );
- else if( p == 11 ) sprintf( buf, "%s/screen.r.%d", fontdir, p );
- else sprintf( buf, "%s/cour.b.%d", fontdir, p );
-
- if( w_font != (Pixfont *) 0 ) pf_close( w_font );
- w_font = pf_open( buf );
- if( w_font == NULL ) { w_font = pw_pfsysopen(); }
- return( w_ppc );
- }
-
- /* ==================== display left adjusted text starting at current position */
- SVtext( s, aw )
- char s[];
- double *aw; /* actual string width in inches (sent back) */
- {
- pw_ttext( w_pw, xsca(oldx), ysca(oldy), (PIX_SRC | PIX_COLOR(color)), w_font, s );
- oldx+= (double)((strlen(s)-1)* w_ppc );
- *aw = xsca_inv( (strlen(s)-1) * w_ppc );
- }
-
- /* ==================== display centered text */
- SVcentext( s, w, x, aw )
- char s[];
- double w;
- double *x; /* actual X starting point in inches (sent back) */
- double *aw; /* actual string width in inches (sent back) */
- {
- double width;
-
- strip_ws( s );
- width = xsca_inv( w_ppc*strlen( s ) );
- SVmoveto( oldx+((w-width)/2.0), oldy );
- SVtext( s, aw );
- *x = xsca_inv((int)( oldx+((w-width)/2.0) ) );
- }
-
- /* ==================== display right-justified text */
- SVrightjust( s, w, x, aw )
- char s[];
- double w;
- double *x; /* actual X starting point in inches (sent back) */
- double *aw; /* actual string width in inches (sent back) */
- {
- double width;
-
- strip_ws( s );
- width = xsca_inv( w_ppc*strlen( s ) );
- SVmoveto( oldx+(w-width), oldy );
- SVtext( s, aw );
- *x = xsca_inv((int)(oldx+(w-width) ));
- }
-
- /* ==================== set the drawing color */
- SVcolor( d, b )
- int d, b;
- {
- color = d; backcolor = b;
- }
-
-
- /* ==================== add to "fill path" */
- SVpath( x, y )
- double x, y;
- {
- if( nv == 0 ) { vlist[0].x = xsca( oldx ); vlist[0].y = ysca( oldy ); nv++; }
- vlist[nv].x = xsca(x);
- vlist[nv].y = ysca(y);
- nv++;
- }
-
- /* ==================== fill prev. defined polygon path with color c */
- SVshade( c )
- double c;
- {
- int n[1];
- Pixrect *pr;
- if( c >= 0.0 && c <= 1.0 ) {
- if( c == 1.0 ) pr = &w_s1_0;
- else if( c > .95 ) pr = &w_s_90;
- else if( c > .90 ) pr = &w_s_80;
- else if( c > .85 ) pr = &w_s_70;
- else if( c > .75 ) pr = &w_s_60;
- else if( c > .65 ) pr = &w_s_50;
- else if( c > .55 ) pr = &w_s_40;
- else if( c > .45 ) pr = &w_s_30;
- else if( c > .35 ) pr = &w_s_20;
- else if( c > .15 ) pr = &w_s_10;
- else if( c >= 0.0 ) pr = &w_s_00;
- else pr = (Pixrect *) 0;
- }
-
- n[0] = nv;
- pw_polygon_2( w_pw, 0, 0, 1, n, vlist, (PIX_SRC | PIX_COLOR((int)(c))), pr, 0, 0 );
- nv = 0;
- }
-
- /* ========= set line dotting attribs ============= */
-
- SVlinetype( t, w, mag )
- char t[];
- double w, mag;
- {
- int i, j, k;
-
- if( strlen( t ) < 1 ) return( 0 );
- if( mag < 1 ) mag = 1;
- if( mag > 4 ) mag = 4;
- w_brush->width = (int)((w*1.6)+0.5);
- w_texture->pattern = w_dash[ (int)mag-1 ][ atoi( t ) % 10 ];
- }
-
- /* ========= batch calls for efficiency ========== */
- SVbatch_on()
- {
- (void) notify_dispatch();
- pw_batch_on( w_pw );
- }
- SVbatch_off()
- {
- (void) notify_dispatch();
- pw_batch_off( w_pw );
- }
-
-
-
- /* =========================================== */
- /* sets up color map, 0 = white, 255 = black, color mixes from 1 to 114 */
- setup_colormap()
- {
- u_char red[256], grn[256], blu[256];
- int i, j;
-
- red[0] = (u_char) 0; /* background color */
- grn[0] = (u_char) 0;
- blu[0] = (u_char) 0;
-
- for (i=0; i<19; i++) {
- red[i + 1] = (u_char) ( 0.99 * 256 ); /* ramp to yellow */
- grn[i + 1] = (u_char) ( 0.055*i * 256 );
- blu[i + 1] = (u_char) ( 0.0 * 256 );
-
- red[i + 20] = (u_char) ( (0.99-0.055*i) * 256 ); /* ramp to green */
- grn[i + 20] = (u_char) ( 0.99 * 256 );
- blu[i + 20] = (u_char) ( 0.0 * 256 );
-
- red[i + 39] = (u_char) ( 0.0 * 256 ); /* ramp to turqouise */
- grn[i + 39] = (u_char) ( 0.99 * 256 );
- blu[i + 39] = (u_char) ( 0.055*i * 256 );
-
- red[i + 58] = (u_char) ( 0.0 * 256 ); /* ramp to blue */
- grn[i + 58] = (u_char) ( ( 0.99-0.055*i ) * 256 );
- blu[i + 58] = (u_char) ( 0.99 * 256 );
-
- red[i + 77] = (u_char) ( 0.055*i * 256 ); /* ramp to violet */
- grn[i + 77] = (u_char) ( 0.0 * 256 );
- blu[i + 77] = (u_char) ( 0.99 * 256 );
-
- red[i + 96] = (u_char) ( 0.99 * 256 ); /* ramp to red */
- grn[i + 96] = (u_char) ( 0.0 * 256 );
- blu[i + 96] = (u_char) ( (0.99-0.055*i) * 256 );
- }
- for( i = 115, j = 0; i < 125; i++, j+= 25 ) red[i] = blu[i] = grn[i] = j;
- for( i = 125, j = 255; i < 256; i++ ) { j = abs(j-255); red[i] = blu[i] = grn[i] = j ; }
-
-
- pw_setcmsname( w_pw, "dots" );
- pw_putcolormap( w_pw, 0, 256, red, grn, blu );
- }
-
-
- SHAR_EOF
- ############################
-
- cat << \SHAR_EOF > src/template.h
- char *Template[350] = { "Proc Areadef:",
- "Area.bottom: 0 to 12 : : Units are inches from lower left.",
- "Area.file: token : : file containing user defined areas",
- "Area.left: 0 to 12 : :",
- "Area.rectangle: 2coordpair : : alternately, two coord-pairs (low left, up right) rectangle",
- "Area.right: 0 to 12 : : | These four must all be used together.",
- "Area.top: 0 to 12 : : ",
- "Area: token : standard : preset graphics area name (see area.coords)",
- "Clone: token : : to inherit parms from a previous Areadef.",
- "Font: font : : standard font to be used on axis labels etc.",
- "Frame: {single,double,none} : none : frame of graphic area ",
- "Saveas: token : : to give this Areadef a name so it can be Cloned later.",
- "Shade: color : : shade of graphic area",
- "Subtitle.above: -12 to 12 (T) : 0.02 : distance of 1st area title line above window top, inches",
- "Subtitle.font: font : : font for area title",
- "Subtitle.justify: {center,left,right} : left : title to be centered, left, or right justified",
- "Subtitle.size: charsize : 10 : char size of title",
- "Subtitle: text : : area title",
- "Xaxis: {bottom,top,both,none} : bottom : where to draw X axis",
- "Xinc: number : 1 : increment.. put a tic mark every n units",
- "Xlabel.position: -12 to 12 (X) : 0.6 : distance of x axis identifier from window bottom, inches",
- "Xlabel.size: charsize : 10 : char size for x axis identifier",
- "Xlabel: text : : x axis identifier",
- "Xmax: number : : maximum in x",
- "Xmin: number : 0 : minimum in x",
- "Xscaletype: {linear,log,yymm} : linear : x scaling discipline",
- "Xstart.0or1: 0 to 10 : 0 : tell x stubs where to start ",
- "Xstub.fileline: number : 0 : line in a stub text file to start at",
- "Xstub.grid: {line,shade,none,wline} : none : form a grid of lines or shaded blocks",
- "Xstub.minor: 0 to 100 : 0 : create this many divisions between regular tics",
- "Xstub.nolonetics: {y,n} : y : if y, no tics will be produced where there are no stubs",
- "Xstub.shade: color : 0.98 : shade for the shaded blocks",
- "Xstub.size: charsize : 7 : char size for stubs",
- "Xstub.startmonth: 1 to 12 : : for month stubs, leftmost month",
- "Xstub.startyear: 0 to 99 : : for month stubs, leftmost year ",
- "Xstub.stubs: {bottom,top,both,none} : bottom : produce labeled axis on left, right, or both sides",
- "Xstub.ticlen.minor: -2 to 2 (X) : 0.035 : length of minor tics in inches (negative inverts it)",
- "Xstub.ticlen: -2 to 2 (X) : 0.08 : length of major tics in inches (negative inverts it)",
- "Xstub.tics: {bottom,top,both,none} : bottom : which side(s) to put tics on",
- "Xstub.yofs: -2 to 2 (X) : 0.2 : distance of stubs up(-) or down(+) from x axis in inches",
- "Xstub: text : num : stubs for tics (num, a file name, a var, or literal)",
- "Xticfmt: token : %4.0f : format for display of numbers in X (like printf)",
- "Yaxis: {left,right,both,none} : left : where to draw Y axis",
- "Yinc: number : 1 : increment.. put a tic mark every n units",
- "Ylabel.position: -12 to 12 (Y) : 0.6 : distance of y axis identifier from window left, inches",
- "Ylabel.size: charsize : 10 : char size for y axis identifier",
- "Ylabel: text : : y axis identifier",
- "Ymax: number : : maximum in y",
- "Ymin: number : 0 : minimum in y",
- "Yscaletype: {linear,log} : linear : y scaling discipline",
- "Ystart.0or1: 0 to 10 : 0 : tell y stubs to start at 0 ",
- "Ystub.fileline: number : 0 : line in a stub text file to start at",
- "Ystub.grid: {line,shade,none,wline} : none : form a grid of lines or shaded blocks",
- "Ystub.minor: 0 to 100 : 0 : create this many divisions between regular tics",
- "Ystub.nolonetics: {y,n} : y : if y, no tics will be produced where there are no stubs",
- "Ystub.shade: color : 0.98 : shade for the shaded blocks",
- "Ystub.size: charsize : 7 : char size for stubs",
- "Ystub.stubs: {left,right,both,none} : left : produce labeled axis on left, right, or both sides",
- "Ystub.ticlen.minor: -2 to 2 (Y) : 0.035 : length of minor tics in inches (negative inverts it)",
- "Ystub.ticlen: -2 to 2 (Y) : 0.08 : length of major tics in inches (negative inverts it)",
- "Ystub.tics: {left,right,both,none} : left : which side(s) to put tics on",
- "Ystub.xofs: -2 to 2 (Y) : 0.1 : distance from y axis to right side of y stub",
- "Ystub: text : num : stubs for tics (num, a file name, a var, or literal)",
- "Yticfmt: token : %4.0f : format for display of numbers in Y (like printf)",
- "Proc Arrow:",
- "Clone: token : :",
- "Points: 2coordpair : : x1, y1, x2, y2. Arrowhead will be at (x2, y2)",
- "Saveas: token : : ",
- "Proc Bargraph:",
- "Clone: token : : to clone an earlier proc's set of parameters",
- "Field: dfield (list8) (M) : : a field for each bar or subbar",
- "Format: {single,cluster,stack} : single : single bars, clusters of bars, or bars stacked up",
- "Idfield.position: -1 to 1 : 0.02 : distance of label above (or below) top of bar (inches)",
- "Idfield.size: charsize : 6 : char size of labels",
- "Idfield: dfield (list8) : : bars can be labeled using these field(s)",
- "Killwild: number : : if a data value greater than this is found, abort ",
- "Outlinebars: {y,n} : y : outline for each bar",
- "Saveas: token : : to save a set of parms for cloning",
- "Segment: {y,n} : n : segment bars at axis tics",
- "Separation.sub: -2 to 2 : 0.03 : separation factor between sub-bars in a cluster",
- "Separation: -2 to 2 : 0.20 : separation factor between major bar spaces ",
- "Shade: color (list8) : .2 .5 .8 1 0 : a shade for each bar or subbar",
- "Xfield: dfield : : X position of bars can be determined by this data field *",
- "Xstart.0or1: {0,1} : 1 : start bars at X=0 or X=1",
- "Zeroat: number : : bars point down at values less than this (usually 0)",
- "Proc Boxplot:",
- "Clone: token : : to clone an earlier proc's set of parameters",
- "Datarow: number : 1 : the row in the data that contains the above 6 values",
- "Ends: {y,n} : y : do little cross-bars on the ends?",
- "Fields: dfield (list6) (M) : : the 6 data fields (see below)",
- "Label.size: charsize : 7 : size of N label in points",
- "Linethick: 0 to 5 : 1 : thickness of boxplot line",
- "Printn: {y,n} : y : print an N=... string at the bottom?",
- "Saveas: token : : to save a set of parms for cloning",
- "Width: number : 0.5 : width of box, in data units",
- "Xloc: number : 0.5 : where box will be centered in x, in data units",
- "Proc Distribution:",
- "Axdist.length: -2 to 2 : 0.08 : length of distribution bars ",
- "Axdist: {y,n} : n : show bar distributions on axes",
- "Clone: token : : to clone an earlier proc's set of parameters",
- "Cluster: {y,n} : y : offset overlaying points slightly to show duplicity",
- "Idfield: dfield : : case identifier may be in this field",
- "Mark.field: dfield : : if specified, mark is contents of this field",
- "Mark.font: font : : font for points",
- "Mark.size: charsize : 6 : size (in point units) for data points",
- "Mark: token : sym6e : symbol code (symNS) or character(s) for points",
- "Saveas: token : : to save a set of parms for cloning",
- "Shadefield: dfield : : if specified, shade of point symbols controlled by field",
- "Shadescale: number : : factor for scaling data to acceptable shade range (0..1)",
- "Sizefield: dfield : : if specified, size of symbols controlled by field ",
- "Sizescale: number : 1 : factor for scaling data to acceptable size (4..20)",
- "Xfield: dfield (M) : : x data comes from this field ",
- "Yfield: dfield : : y data field. If Yfield ommitted, do a bar distr.",
- "Proc Draw:",
- "Clone: token : : to clone an earlier proc's set of parameters",
- "Linethick: 0.1 to 10 : 1 : thickness of line",
- "Linetype.magnify: 0.1 to 10 : 1 : magnification of patterns",
- "Linetype: 0 to 8 : 0 : line dash pattern",
- "Points: text (M) (C) : : coord pairs, 2 per line (move+draw) or 1 per line (draw)",
- "Saveas: token : : to save a set of parms for cloning",
- "System: {data,absolute} : absolute : which coord system points are in",
- "Proc Errorbars:",
- "Clone: token : : to clone an earlier proc's set of parameters",
- "Double: {y,n} : y : display 2 times the error amount?",
- "Errfield: dfield (M) : : field containing error amount in y",
- "Linethick: 0 to 10 : 0.3 : line thickness for error bars",
- "Offset: -1 to 1 : 0 : amount of offset in X, in inches",
- "Saveas: token : : to save a set of parms for cloning",
- "Taillen: 0 to 1 : 0.04 : width of tails at the end of the bars",
- "Xfield: dfield (M) : : field containing point x location",
- "Yfield: dfield (M) : : field containing point y location",
- "Proc Getdata:",
- "Append: {y,n} : n : if y, new data will be put below existing data",
- "Clone: token : : to clone an earlier proc's set of parameters",
- "Data: text : : following lines contain data",
- "Datafile: token (M) : : file name, '-' (terminal), or a Unix command ",
- "Join: {y,n} : n : if y, new data will be put beside existing data",
- "Percents: dfield (list20) : : change these fields from N to percentages, based on total",
- "Saveas: token : : to save a set of parms for cloning",
- "Selectfields: token (list20) : all : select only these fields from input",
- "Startline: number : 1 : line to start with (first line is line 1)",
- "Stopline: number : 9999 : stop reading after this line is read",
- "Proc Legend:",
- "Backshade: color : : shade for backing box",
- "Clone: token : : to clone an earlier proc's set of parameters",
- "Corner: {A,B,C,D} : A : which corner of the area, clockwise from upperleft",
- "Entry.font: font : : font for legend entries",
- "Entry.size: charsize : 7 : char size for legend entries",
- "Entry: text (M) : : text for legend entries, one per line ",
- "Linethick: number (list10) : 1 1 1 1 1 1 1 1 1 1 : thickness of line(s)",
- "Linetype.magnify: number (list10) : 3 3 3 3 3 3 3 3 3 3 : mag. factor for dash pattern",
- "Linetype: number (list10) : : line dash type for (each) line",
- "Location.system: {absolute,data} : absolute : coord system for the above",
- "Location: coordpair : : location for upperleft of legend",
- "Mark.font: font : : ",
- "Mark.size: charsize : 7 :",
- "Mark: list : : list of marks for legend entries (symNS or chars)",
- "Outlinebars: {y,n} : n : ' '",
- "Saveas: token : : to save a set of parms for cloning",
- "Shade: color (list10) : : for bar graphs",
- "Title.size: charsize : 10 : size for legend title",
- "Title: text : : legend title",
- "Proc Lineplot:",
- "Accum: {y,n} : n : option to accumulate yalues of y",
- "Clone: token : : to clone an earlier proc's set of parameters",
- "Label.size: charsize : 8 : char size for line identifier",
- "Label: text : : curve identifier, one per line",
- "Linethick: 0 to 10 (list8) : 1 1 1 1 1 1 1 1 : thickness of line(s)",
- "Linetype.magnify: 0 to 10 (list8) : 3 3 3 3 3 3 3 3 : mag. factor for dash pattern",
- "Linetype: 0 to 8 (list8) : 0 1 2 3 4 5 6 7 : line dash type for (each) line",
- "Mark.size: charsize : 7 : Size for mark chars",
- "Mark: list : : Mark char for points, one per line",
- "Numberfinal: {y,n} : n : display y value of rightmost point",
- "Numbers.offset: -1 to 1 : 0.015 : abs distance of numbers (+) above or (-)below line",
- "Numbers: {y,n} : n : display y value at each point",
- "Saveas: token : : to save a set of parms for cloning",
- "Shade: color (list8) : : shading below lines",
- "Stairstep.bars: {y,n} : n : for superimposing line over bar graph (moves it 1/2)",
- "Stairstep: {y,n} : n : lines form steps rather than diagonals",
- "Xfield: dfield : : line's x data field (optional)",
- "Xstart.0or1: {0,1} : 0 : if no x data field specified, start on or beside origin",
- "Yfield: dfield (list8) (M) : : list of y fields for each line ",
- "Zeroat: number : 0 : point for zero crossing with shading ",
- "Proc Map:",
- "Clone: token : : to clone an earlier proc's set of parameters",
- "Country.linethick: 0.1 to 5 : 1 : thickness for country boundary lines",
- "Country: {usa,usa+canada} : usa+canada : map format",
- "List: {y,n} : y : list state distribution down right side",
- "Mode: {country,state,statedist} : state : country outln, state outln, or state distribution",
- "Saveas: token : : to save a set of parms for cloning",
- "Shade: color (list10) : 1 .9 .8 .6 .4 .2 : shades corresponding to the above thresholds",
- "State.linethick: 0.1 to 5 : 0.2 : thickness for state boundary lines",
- "Statefield: dfield : : field in which standard state/province name can be found",
- "Threshold: number (list10) : : thresholds for shading (don't include 0 or max)",
- "Valfield: dfield : : field in which n value can be found",
- "Proc Nicetab:",
- "Area.rectangle: 2coordpair : : two coord pairs (low left, up right) defining area",
- "Area: token :nicetab : a pre-defined area name, see area.coords",
- "Body.font: font : : body font",
- "Body.only: {y,n} : n : indicates no title present, process all as table body.",
- "Body.size: token : 8 : body char size",
- "Clone: token : : to clone an earlier proc's set of parameters",
- "File: token (M) : : file containing ascii table",
- "Saveas: token : : to save a set of parms for cloning",
- "Title.font: font : : title font",
- "Title.size: charsize : 11 : title char size",
- "Proc Page:",
- "Clone: token : : to clone an earlier proc's set of parameters",
- "Paperway: {portrait,landscape,screen} : portrait : the way paper will be held to look at",
- "Saveas: token : : to save a set of parms for cloning",
- "Standard.font: font : /Helvetica : default font for everything on page",
- "Standard.linethick: 0 to 6 : 1 : standard line thickness",
- "Title.belowtop: -12 to 12 (T) : 0.2 : distance of 1st title line below top of page",
- "Title.file: token : : file containing title",
- "Title.font: font : : font for page title",
- "Title.size: charsize : 12 : char size of title",
- "Title: text : : window title",
- "Proc Pagebreak:",
- "Clone: token : : this is not really useful, but all procs must have this",
- "Saveas: token : : this is not really useful, but all procs must have this",
- "Proc Pie:",
- "Field: dfield (M) : : Data field to use. Numbers should be integer percentages.",
- "Center: coordpair : 4.0 5.5 : Location of center, in absolute units." ,
- "Radius: 0 to 5 : 3 : Radius of pie, in absolute units.",
- "Shade: color list20 : : Shades of pie sections",
- "Linethick: 0 to 10 : 1 : Thickness of lines",
- "Explode: 0 to 3 : 0.1 : Distance in abs units to 'explode' each piece",
- "Rotate: 0 to 360 : 0 : Rotate entire pie this many degrees counterclockwise",
- "Clone: token : :",
- "Saveas: token : :",
- "Proc Point:",
- "Clone: token : : ",
- "Mark: token : sym6e : symbol code (see example point1.g)",
- "Position: text (M) (C) : : position in absolute data system",
- "Saveas: token : : ",
- "Size: 1 to 20 : 5 : marker size",
- "Proc Polygon:",
- "Clone: token : : to clone an earlier proc's set of parameters",
- "Linethick: 0.1 to 10 : 1 : thickness of line for outline",
- "Linetype.magnify: 0.1 to 10 : 1 : magnification of patterns for outline",
- "Linetype: 0 to 8 : 0 : line dash pattern for outline",
- "Outline: {y,n} : n : outline polygon with a line?",
- "Points: text (M) (C) : : one coord pair per line (points making up a polygon)",
- "Rectangle: 2coordpair : : (lower left and upper right) for a rectangle, abs units ",
- "Saveas: token : : to save a set of parms for cloning",
- "Shade: color : 0.5 : shade of polygon",
- "System: {data,absolute} : absolute : which coord system points are in",
- "Proc QuitAppend:",
- "Clone: token : : ",
- "Saveas: token : : ",
- "Proc Rangebar:",
- "Clone: token : : to clone an earlier proc's set of parameters",
- "Ends: {y,n} : y : do little cross-bars on the ends?",
- "Field: dfield (list5) (M) : : data fields (should have Nval members)",
- "Idfield: dfield : : data field holding id label",
- "Label.position: number : 1 : position for N=.. label in Y data units",
- "Label.size: charsize : 6 : size of the above label in points",
- "Linethick: 0 to 5 : 1 : thickness of boxplot line",
- "Midlineright: {y,n} : n : option for making median lines protrude right only",
- "Midlinewidth: number : 0 : size of median line in user units, 0 uses Width value",
- "Nval: 1 to 5 : 5 : number of values making up the box",
- "Saveas: token : : to save a set of parms for cloning",
- "Shade: color : 1.0 : shade for inside of bar",
- "Width: number : 0.3 : width of box, in data units",
- "Xfield: dfield : : (optional) data field, bar x placement",
- "Proc Text:",
- "Clone: token : : to clone an earlier proc's set of parameters",
- "Direction: 0 to 359 : 0 : direction of text in degrees counterclockwise",
- "File: token : : file containing text",
- "Embeddedcoords: {y,n} : n : if y look for x and y values at beginning of each line",
- "Font: font : : font to use",
- "Position: coordpair (M) : : location of beginning of 1st text line",
- "Saveas: token : : to save a set of parms for cloning",
- "Size: charsize : 10 : size of text",
- "System: {data,absolute} : absolute : which coord system position is in",
- "Text: text : : the text itself",
- "Proc Vbargraph:",
- "Clone: token : : to clone an earlier proc's set of parameters",
- "Field: dfield (list8) : : a field for each bar and subbar",
- "Format: {single,cluster,stack} : single : single bars, clusters of bars, or bars stacked up",
- "Idfield.position: -1 to 1 : 0.02 : distance of label above (or below) top of bar (inches)",
- "Idfield.size: charsize : 6 : char size of labels",
- "Idfield: dfield (list8) : : bars can be labeled using these field(s)",
- "Killwild: number : : if a data value greater than this is found, abort ",
- "Outlinebars: {y,n} : y : outline for each bar",
- "Saveas: token : : to save a set of parms for cloning",
- "Segment: {y,n} : n : segment bars at axis tics",
- "Separation.sub: 0 to 1 : 0.03 : distance between sub-bars in cluster",
- "Separation: 0 to 1 : 0.20 : distance between major bar spaces",
- "Shade: color (list8) : .2 .5 .8 1 0 : a shade for each bar and subbar",
- "Yfield: dfield : : Y position of bars (optional)",
- "Ystart.0or1: {0,1} : 1 : start bars at Y=0 or Y=1",
- "Zeroat: number : : bars point down at values less than this (usually 0)",
- "Proc Vector:",
- "Point1fields: dfield (list2) (M) : :fields in data holding x and y describing point p1 (x,y)",
- "Point2fields: dfield (list2) (M) : :fields in data holding x and y describing point p2 (x,y)",
- "Headlength: 0 to 2 : 0.2 :determines size of arrowhead, length in inches from point",
- "Headwidth: 0 to 0.8 : 0.24 :determines size of arrowhead, arc of half of arrow in radians",
- "Headshade: color : 0.0 :color of arrowhead",
- "Saveas: token : : to save a set of parms for cloning",
- "Clone: token : : to clone an earlier proc's set of parameters",
- "Proc Vrangebar:",
- "Clone: token : : to clone an earlier proc's set of parameters",
- "Ends: {y,n} : y : do little cross-bars on the ends?",
- "Field: dfield (list5) (M) : : data fields (should have Nval members)",
- "Idfield: dfield : : data field holding id label",
- "Label.size: charsize : 6 : size of the above label in points",
- "Label.position: number : 1 : position for N=.. label in Y data units",
- "Linethick: 0 to 5 : 1 : thickness of boxplot line",
- "Midlinewidth: number : 0 : size of median line in user units, 0 uses Width value",
- "Midlineright: {y,n} : n : option for making median lines protrude right only",
- "Nval: 1 to 5 : 5 : number of values making up the box",
- "Saveas: token : : to save a set of parms for cloning",
- "Shade: color : 1.0 : shade for inside of bar",
- "Width: number : 0.3 : width of box, in data units",
- "Yfield: dfield : : (optional) data field, bar x placement",
- "", "", "" } ;
-
- /* number of lines per proc */
- int Tdx[30] = { 0,
- 64, /* Areadef */
- 4, /* Arrow */
- 17, /* Barg */
- 11, /* Boxp */
- 17, /* Dist */
- 8, /* Draw */
- 10, /* Errorbars */
- 11, /* Getdata */
- 20, /* Legend */
- 21, /* Linep */
- 12, /* Map */
- 11, /* Nicetab */
- 11, /* Page */
- 3, /* Pagebreak */
- 10, /* Pie */
- 6, /* Point */
- 11, /* Polygon */
- 3, /* QuitAppend */
- 15, /* Rangebar */
- 11, /* Text */
- 17, /* Vbar */
- 8, /* Vector */
- 15, /* Vrangebar */
- 0, 0, 0, 0 };
-
- /* Note, only one space allowed after word "Proc" */
- SHAR_EOF
- ############################
-
- cat << \SHAR_EOF > src/text.c
- #include "ipl.x"
- #define DATA 0
- #define ABSOLUTE 1
-
- Text( )
- {
- int sys, ln, embedded, p, ix;
- double x, y, theta, size;
- char s1[40], s2[40];
- FILE *fp;
-
- gget( Buf, "System" );
- if( Buf[0] == 'd' ) {
- sys = DATA;
- if( DXlo == 0 && DXhi == 0 ) { fprintf( stderr, "No graphics area.\n" ); gdp_exit(); }
- }
- else sys = ABSOLUTE;
-
- gget( Buf, "Font" ); NTfont( Buf );
- gget( Buf, "Size" ); size = atof( Buf ); NTptsize( size );
- gget( Buf, "Position" );
- sscanf( Buf, "%lf %lf", &x, &y );
- gget( Buf, "Direction" ); theta = atof( Buf );
-
- if( theta != 0 ) NTchardir( theta );
-
- gget( Buf, "Embeddedcoords" );
- if( Buf[0] == 'y' ) embedded = 1; else embedded = 0;
-
- gget( Buf, "File" );
- if( strlen( Buf ) > 0 ) fp = fopen( Buf, "r" ); /* text in a file */
- else { /* text given-- put it in a file */
- gget( Buf, "Text" );
- text_tofile( Buf, Tempfile );
- fp = fopen( Tempfile, "r" );
- }
- if( fp == NULL ) { fprintf( stderr, "Cant open text file" ); gdp_exit(); }
-
- /* read the file and print the text */
- if( !embedded ) {
- if( sys == DATA ) NTm( x, y );
- else NTmov( x, y );
- }
-
- ln = 1;
- while( fgets( Buf, 200, fp ) != NULL ) {
- if( embedded ) {
- ix = 0;
- strcpy( s1, getok( Buf, &ix ) );
- strcpy( s2, getok( Buf, &ix ) );
- if( goodnum( s1, &p ) && goodnum( s2, &p ) ) {
- x = atof( s1 ); y = atof( s2 );
- if( sys == DATA ) NTm( x, y );
- else NTmov( x, y );
- strcpy( Buf, &Buf[ix] );
- strip_ws( Buf );
- }
- }
- NTtext( Buf );
- if( sys == DATA ) NTmov( da_x(x), da_y(y)-(ln*Chh) );
- else NTmov( x, y-(ln*Chh) );
- ln++;
- }
-
- fclose( fp );
- NTchardir( 0 );
- }
- SHAR_EOF
- ############################
-
-
-