Exemple #1
0
int
PLP_annotate()
{
char attr[NAMEMAXLEN], val[256];
char *line, *lineval;
int nt, lvp;
int first;

int align;
double adjx, adjy;
double x, y;
char textdetails[256];
char fromfile[256];
int fromfilemode;
int nlines, maxlen;
char box[256];
char backcolor[COLORLEN];
int verttext;
double bm;
char mapurl[MAXPATH];
double bevelsize, shadowsize;
char lowbevelcolor[COLORLEN], hibevelcolor[COLORLEN], shadowcolor[COLORLEN];
int ioutline;
char maplabel[MAXTT];
int clickmap_on;
int do_ellipse;
double bd_1, bd_2, bd_3, bd_4;
int backdim;
double cx, cy, px, py;
int clip;


TDH_errprog( "pl proc annotate" );

/* initialize */
strcpy( PL_bigbuf, "" );
strcpy( textdetails, "" );
strcpy( fromfile, "" );
fromfilemode = 0;
x = 3.0;
y = 3.0;
arrowh = arrowt = 0;
arrow2h = arrow2t = 0;
strcpy( arrowdet, "" );
ahsize = 0.1;
strcpy( box, "" );
strcpy( backcolor, "" );
verttext = 0;
bm = 0.0;
strcpy( mapurl, "" );
bevelsize = 0.0;
shadowsize = 0.0;
strcpy( lowbevelcolor, "0.6" );
strcpy( hibevelcolor, "0.8" );
strcpy( shadowcolor, "black" );
strcpy( maplabel, "" );
clickmap_on = 0;
do_ellipse = 0;
backdim = 0;
clip = 0;




/* get attributes.. */
first = 1;
while( 1 ) {
	line = getnextattr( first, attr, val, &lvp, &nt );
	if( line == NULL ) break;
	first = 0;
	lineval = &line[lvp];


	if( stricmp( attr, "location" )==0 ) {
		getcoords( "location", lineval, &x, &y );
		}
	else if( stricmp( attr, "text" )==0 ) 
		getmultiline( "text", lineval, MAXBIGBUF, PL_bigbuf );

	else if( stricmp( attr, "textdetails" )==0 ) strcpy( textdetails, lineval );
	else if( stricmp( attr, "fromfile" )==0 ) {
		strcpy( fromfile, lineval );
		fromfilemode = 1;
		}
	else if( stricmp( attr, "fromcommand" )==0 ) {
		strcpy( fromfile, lineval );
		fromfilemode = 2;
		}

	else if( stricmp( attr, "arrowhead" )==0 ) {
		getcoords( "arrowhead", lineval, &ahx, &ahy );
		arrowh = 1;
		}
	else if( stricmp( attr, "arrowtail" )==0 ) {
		getcoords( "arrowtail", lineval, &atx, &aty );
		arrowt = 1;
		}
	else if( stricmp( attr, "arrowhead2" )==0 ) {
		getcoords( "arrowhead2", lineval, &ah2x, &ah2y );
		arrow2h = 1;
		}
	else if( stricmp( attr, "arrowtail2" )==0 ) {
		getcoords( "arrowtail2", lineval, &at2x, &at2y );
		arrow2t = 1;
		}
	else if( stricmp( attr, "arrowdetails" )==0 ) strcpy( arrowdet, lineval );
	else if( stricmp( attr, "arrowheadsize" )==0 ) {
		ahsize = atof( val );
		if( ahsize <= 0.0 ) ahsize = 0.0; /* no arrow */
		if( PLS.usingcm ) ahsize /= 2.54;
		}
	else if( stricmp( attr, "box" )==0 || stricmp( attr, "outline" )==0 ) strcpy( box, lineval );
	else if( stricmp( attr, "ellipse" )==0 ) {
		if( strnicmp( val, YESANS, 1 )==0 ) do_ellipse = 1;
		else do_ellipse = 0;
		}
	else if( stricmp( attr, "clickmapurl" )==0 ) {
		if( PLS.clickmap ) { strcpy( mapurl, val ); clickmap_on = 1; }
		}
	else if( stricmp( attr, "clickmaplabel" )==0 ) {
		if( PLS.clickmap ) { strcpy( maplabel, lineval ); clickmap_on = 1; }
		}
        else if( stricmp( attr, "clickmaplabeltext" )==0 ) {
                if( PLS.clickmap ) { getmultiline( "clickmaplabeltext", lineval, MAXTT, maplabel ); clickmap_on = 1; }
                }

	else if( stricmp( attr, "boxmargin" )==0 ) {
		bm = atof( val );
		if( PLS.usingcm ) bm /= 2.54;
		}
	else if( stricmp( attr, "verttext" )==0 ) {
		if( strnicmp( val, YESANS, 1 )==0 ) verttext = 1;
		else verttext = 0;
		}
	else if( stricmp( attr, "backcolor" )==0 ) strcpy( backcolor, val );
	else if( stricmp( attr, "bevelsize" )==0 ) bevelsize = atof( val );
        else if( stricmp( attr, "shadowsize" )==0 ) shadowsize = atof( val );
        else if( stricmp( attr, "lowbevelcolor" )==0 ) strcpy( lowbevelcolor, val );
        else if( stricmp( attr, "hibevelcolor" )==0 ) strcpy( hibevelcolor, val );
        else if( stricmp( attr, "shadowcolor" )==0 ) strcpy( shadowcolor, val );
	else if( stricmp( attr, "backdim" )==0 ) {
		PL_getbox( "backdim", lineval, &bd_1, &bd_2, &bd_3, &bd_4 );
		backdim = 1;
		}
        else if( stricmp( attr, "clip" )==0 ) {
		if( strnicmp( val, YESANS, 1 )==0 ) clip = 1;
		else clip = 0;
		}
	else Eerr( 1, "attribute not recognized", attr );
	}


if( fromfilemode > 0 ) file_to_buf( fromfile, fromfilemode, PL_bigbuf, MAXBIGBUF );

textdet( "textdetails", textdetails, &align, &adjx, &adjy, 0, "R", 1.0 );
if( align == '?' ) align = 'C';

px = x + adjx;
py = y + adjy;

/* figure backing box */
measuretext( PL_bigbuf, &nlines, &maxlen );
boxw = (maxlen+2) * Ecurtextwidth;
boxh = (nlines*1.2) * Ecurtextheight;
uly = py + Ecurtextheight;
if( align == 'C' ) ulx = px - (boxw/2.0); 
else if( align == 'L' ) ulx = px;
else if( align == 'R' ) ulx = px - boxw;


if( bm != 0.0 ) {
	ulx -= bm;
	uly += bm;
	boxw += (bm*2);
	boxh += (bm*2);
	}

if( clip ) PLG_pcodeboundingbox( 0 ); /* clip the annotation to the cropped size (by turning off bb) */

if( backcolor[0] != '\0' || ( box[0] != '\0' && strnicmp( box, "no", 2 )!= 0 ) ) {
	if( box[0] != '\0' && strnicmp( box, "no", 2 )!= 0 ) {
		ioutline = 1;
		linedet( "box", box, 0.5 );
		}
	else ioutline = 0;
	if( do_ellipse ) {
		cx = ulx+(boxw/2.0);
		cy = uly-(boxh/2.0);
		if( backdim ) { cx = bd_1; cy = bd_2; boxw = bd_3; boxh = bd_4; }
		do_arrows(); /* do this before ellipse to get abutting edge */
		PLG_ellipse( cx, cy, ((boxw/2.0)*1.3), ((boxh/2.0)*1.3), backcolor, ioutline );
		}
	else	{
		if( backdim ) { ulx = bd_1; uly = bd_2; boxw = bd_3; boxh = bd_4; }
		do_arrows(); /* do this before fill to get abutting edge */
		Ecblock( ulx, (uly-boxh), ulx+boxw, uly, backcolor, ioutline );
		if( bevelsize > 0.0 || shadowsize > 0.0 ) 
			Ecblockdress( ulx, (uly-boxh), ulx+boxw, uly, bevelsize, lowbevelcolor, hibevelcolor, shadowsize, shadowcolor);
		}
	}
else do_arrows();

if( clickmap_on ) {
	if( backdim && do_ellipse ) {
		/* need to solve back to ulx,uly in this case.. */
		ulx = (((boxw/2.0)-cx)*-1.0); 
		uly = (((boxw/2.0)-cy)*-1.0) + boxh; 
		}
	clickmap_entry( 'r', mapurl, 0, ulx, (uly-boxh), ulx+boxw, uly, 1, 0, maplabel );
	}

/* now render the text.. */
textdet( "textdetails", textdetails, &align, &adjx, &adjy, 0, "R", 1.0 ); /* need to do again */
if( align == '?' ) align = 'C';
Emov( x + adjx, y + adjy );
if( verttext ) Etextdir( 90 );
Edotext( PL_bigbuf, align );
if( verttext ) Etextdir( 0 );

if( clip ) PLG_pcodeboundingbox( 1 ); /* restore */

return( 0 );
}
Exemple #2
0
int
PLP_page( )
{
int lvp, first;
char attr[NAMEMAXLEN], *line, *lineval;

char buf[512], devval[20];
char *outfilename, *mapfilename, *titledet, *pagetitle, *url;
int stat, nt, align, nlines, maxlen, landscapemode, dobackground, dopagebox, pagesizegiven, clickmap_enabled_here, tight, map;
double adjx, adjy, scalex, scaley, sx, sy;

TDH_errprog( "pl proc page" );

/* initialize */
landscapemode = PLS.landscape; /* from command line */
titledet = "";
outfilename = "";
mapfilename = "";
pagetitle = "";
dobackground = 1;
dopagebox = 1;
if( GL_member( PLS.device, "gesf" )) dopagebox = 0; /* bounding box shouldn't include entire page for gif , eps */
if( PLS.device == 'e' ) dobackground = 0; 
pagesizegiven = 0;
strcpy( devval, "" );
scalex = scaley = 1.0;
clickmap_enabled_here = 0;

/* get attributes.. */
first = 1;
while( 1 ) {
        line = getnextattr( first, attr, &lvp );
        if( line == NULL ) break;
        first = 0;
        lineval = &line[lvp];


	/* if an attribute is given on command line, it overrides anything here.. */
	if( GL_slmember( attr, PLS.cmdlineparms )) continue;
	if( strcmp( attr, "landscape" )==0 && GL_slmember( "portrait", PLS.cmdlineparms )) continue;
	if( strcmp( attr, "outfilename" )==0 && GL_slmember( "o", PLS.cmdlineparms )) continue;

	if( strcmp( attr, "landscape" )==0 ) landscapemode = getyn( lineval );
	else if( strcmp( attr, "title" )==0 ) pagetitle = getmultiline( lineval, "get" ); 
	else if( strcmp( attr, "titledetails" )==0 ) titledet = lineval;
	else if( strcmp( attr, "color" )==0 ) tokncpy( Estandard_color, lineval, COLORLEN );
	else if( strcmp( attr, "scale" )==0 ) { 
		nt = sscanf( lineval, "%lf %lf", &scalex, &scaley ); 
		if( nt == 1 ) scaley = scalex; 
		}
	else if( strcmp( attr, "backgroundcolor" )==0 ) {
		tokncpy( Estandard_bkcolor, lineval, COLORLEN );
		Ebackcolor( Estandard_bkcolor );
		dobackground = 1; /* added scg 9/27/99 */
		}
	else if( strcmp( attr, "linewidth" )==0 ) Estandard_lwscale = ftokncpy( lineval );
	else if( strcmp( attr, "textsize" )==0 ) Estandard_textsize = itokncpy( lineval );
	else if( strcmp( attr, "font" )==0 ) tokncpy( Estandard_font, lineval, FONTLEN );
	else if( strcmp( attr, "dobackground" )==0 ) dobackground = getyn( lineval );
	else if( strcmp( attr, "dopagebox" )==0 ) dopagebox = getyn( lineval );
	else if( strcmp( attr, "tightcrop" )==0 ) { tight = getyn( lineval ); Etightbb( tight ); }
	else if( strncmp( attr, "crop", 4 )==0 ) {
		double cropx1, cropy1, cropx2, cropy2;
		nt = sscanf( lineval, "%lf %lf %lf %lf", &cropx1, &cropy1, &cropx2, &cropy2 );
		if( nt != 4 ) Eerr( 2707, "usage: crop x1 y1 x2 y2 OR croprel left bottom right top", "" );
		else {
			if( PLS.usingcm ) { cropx1 /= 2.54; cropy1 /= 2.54; cropx2 /= 2.54; cropy2 /= 2.54; }
			if( strcmp( attr, "croprel" )==0 ) Especifycrop( 2, cropx1, cropy1, cropx2, cropy2 ); /* relative to tight */
			else Especifycrop( 1, cropx1, cropy1, cropx2, cropy2 ); /* absolute */
			}
		}

	else if( strcmp( attr, "pixsize" ) ==0 ) {  /* added scg 1/9/08 */
		int reqwidth, reqheight;
		nt = sscanf( lineval, "%d %d", &reqwidth, &reqheight );
		if( nt != 2 ) Eerr( 57233, "pixsize ignored.. it requires width and height (in pixels)", "" );
#ifndef NOGD
        	PLGG_setimpixsize( reqwidth, reqheight );
#endif
        	if( PLS.device != 'g' ) Eerr( 24795, "pixsize ignored.. it's only applicable when generating png/gif/jpeg images", "" ); 
		}

	else if( strcmp( attr, "pagesize" )==0 ) {
		getcoords( "pagesize", lineval, &(PLS.winw), &(PLS.winh) );
		pagesizegiven = 1;
		}
	else if( strcmp( attr, "outfilename" )==0 ) {
		outfilename = lineval;
		if( strlen( outfilename ) > MAXPATH-1 ) { PLS.skipout = 1; return( Eerr( 57932, "outfilename too long", "" ) ); }  
		}
	else if( strncmp( attr, "mapfile", 7 )==0 ) {
		mapfilename = lineval;
		if( strlen( mapfilename ) > MAXPATH-1 ) { Eerr( 57932, "mapfile name too long", "" ); mapfilename = ""; }
		}

	else if( strcmp( attr, "clickmapdefault" )==0 ) { 
		url = lineval;
		if( strlen( url ) > MAXURL-1 ) Eerr( 57933, "clickmapdefault url too long", "" );
		else clickmap_setdefaulturl( url ); 
		}

	else if( strcmp( attr, "map" )==0 ) { map = getyn( lineval ); if( map ) { PLS.clickmap = 1; clickmap_enabled_here = 1; }}
	else if( strcmp( attr, "csmap" )==0 ){ map = getyn( lineval ); if( map ) { PLS.clickmap = 2; clickmap_enabled_here = 1; }} 
	else if( strcmp( attr, "outlabel" )==0 ) Esetoutlabel( lineval );
	else Eerr( 1, "page attribute not recognized", attr );
	}



/* -------------------------- */
/* Page break logic.. */
/* -------------------------- */
if( PLS.npages == 0 ) {

	/* following 3 lines moved here from above - also replicated below.  scg 10/31/00 */
	if( scalex != 1.0 || scaley != 1.0 ) Esetglobalscale( scalex, scaley );
	Egetglobalscale( &sx, &sy );
	if( pagesizegiven ) Esetsize( PLS.winw * sx, PLS.winh * sy, PLS.winx, PLS.winy );
	else if( landscapemode && !PLS.winsizegiven ) Esetsize( 11.0, 8.5, PLS.winx, PLS.winy ); /* landscape */

	/* clickmap (must come before init for eg. svg - scg 2/7/05) */
	if( clickmap_enabled_here ) {
		if( mapfilename[0] == '\0' ) {
        		if( PLS.clickmap == 2 ) strcpy( PLS.mapfile, "stdout" );  /* csmap defaults to stdout..  scg 8/26/04  */
        		else if( PLS.outfile[0] != '\0' ) makeoutfilename( PLS.outfile, PLS.mapfile, 'm', 1);
        		else strcpy( PLS.mapfile, "unnamed.map" );
        		}
		PL_clickmap_init();
#ifndef NOSVG
		/* must update this now too.. scg 2/7/05  */
		if( PLS.device == 's' ) PLGS_setparms( PLS.debug, PLS.tmpname, PLS.clickmap );
#endif
		}
	else if( mapfilename[0] != '\0' ) strcpy( PLS.mapfile, mapfilename ); /* PPP */

	/* initialize and give specified output file name .. */
	if( outfilename[0] != '\0' ) Esetoutfilename( outfilename );
	stat = Einit( PLS.device );
	if( stat ) { PLS.skipout = 1; return( stat ); }

	/* set paper orientation */
	if( landscapemode ) Epaper( 1 );

	}


else if( PLS.npages > 0 ) {

	if( GL_member( PLS.device, "gesf" )) {

		/* finish up current page before moving on to next one.. */
		Eshow();
		stat = Eendoffile();
		if( stat ) return( stat );

		/* now set file name for next page.. */
		if( outfilename[0] != '\0' ) Esetoutfilename( outfilename );
		else	{
			makeoutfilename( PLS.outfile, buf, PLS.device, (PLS.npages)+1 );
			if( PLS.debug ) fprintf( PLS.diagfp, "Setting output file name to %s\n", PLS.outfile );
			Esetoutfilename( buf );
			}

		if( PLS.clickmap ) {
			/* initialize a new click map file.. */
			if( mapfilename[0] != '\0' ) strcpy( PLS.mapfile, mapfilename );
			else makeoutfilename( PLS.outfile, PLS.mapfile, 'm', (PLS.npages)+1 );
			PL_clickmap_init();

			}


		/* perhaps set global scaling and/or page size for next page.. */
		/* following 3 lines copied here from above - scg 10/31/00 */
		if( scalex != 1.0 || scaley != 1.0 ) Esetglobalscale( scalex, scaley );
		Egetglobalscale( &sx, &sy ); 
		if( pagesizegiven ) Esetsize( PLS.winw * sx, PLS.winh * sy, PLS.winx, PLS.winy );
		else if( landscapemode && !PLS.winsizegiven ) Esetsize( 11.0, 8.5, PLS.winx, PLS.winy ); /* landscape */

		/* initialize next page.. */
		stat = Einit( PLS.device );
		if( stat ) return( stat );
		}

	else if ( PLS.device == 'x' ) PL_do_x_button( "More.." );

	else if ( GL_member( PLS.device, "pc" ) ) {
		Eprint();
		if( landscapemode ) Epaper( 1 ); /* added scg 2/29/00 */
		Elinetype( 0, 0.6, 1.0 );   /* added scg 9/20/99 */
		}
	}
(PLS.npages)++;


/* -------------------------- */
/* now do other work.. */
/* -------------------------- */


/* do background.. */
/* if( dopagebox ) Ecblock( 0.0, 0.0, EWinx, EWiny, Ecurbkcolor, 0 ); */ /* does update bb */
if( dopagebox ) Ecblock( 0.0, 0.0, PLS.winw, PLS.winh, Ecurbkcolor, 0 ); /* does update bb */
else if( dobackground ) {
	/* EPS color=transparent - best to do nothing.. */
        if( PLS.device == 'e' && strcmp( Ecurbkcolor, "transparent" )==0 ) ;

        else Eclr(); /* doesn't update bb */
	}

if( pagetitle[0] != '\0' ) {
	textdet( "titledetails", titledet, &align, &adjx, &adjy, 3, "B", 1.0 );
	if( align == '?' ) align = 'C';
	measuretext( pagetitle, &nlines, &maxlen );
	if( align == 'L' ) Emov( 1.0 + adjx, (PLS.winh-0.8) + adjy );
	else if ( align == 'C' ) Emov( (PLS.winw / 2.0 ) + adjx, (PLS.winh-0.8) + adjy );
	else if( align == 'R' ) Emov( (PLS.winw-1.0) + adjx, (PLS.winh-0.8) + adjy );
	Edotext( pagetitle, align );
	}

return( 0 );
}
Exemple #3
0
int
PLP_venndisk()
{
char attr[NAMEMAXLEN], val[256];
char *line, *lineval;
int first, nt, lvp;
double cenx, ceny, area, radius;
char color[COLORLEN];
char leglabel[128];
double densfact;
char outline[128];
double ofs;
int botflag;
double areascale;
int datadriven, xfld, areafld, clrfld;
double yloc;
int irow;
double y;
int solidfill;
int lblfld;
char lbldet[128];
double adjx, adjy;
int align;

TDH_errprog( "pl proc venn" );

cenx = ceny = area = -1.0;
densfact = 1.0;
strcpy( leglabel, "" );
strcpy( color, "red" );
strcpy( outline, "" );
botflag = 0;
areascale = 1.0;
ofs = 0.0;
datadriven = xfld = areafld = clrfld = 0;
yloc = 0.5;
solidfill = 0;
lblfld = 0;
strcpy( lbldet, "" );

/* get attributes.. */

first = 1;
while( 1 ) {
	line = getnextattr( first, attr, val, &lvp, &nt );
	if( line == NULL ) break;
	first = 0;
	lineval = &line[lvp];

	if( stricmp( attr, "location" )==0 ) getcoords( "location", lineval, &cenx, &ceny );
	else if( stricmp( attr, "bottomlocation" )==0 ) {
		getcoords( "bottomlocation", lineval, &cenx, &ceny ); /* given in scale units */
		botflag = 1;
		}
	else if( stricmp( attr, "area" )==0 ) area = atof( val );        /* square inches unless areascale given */
	else if( stricmp( attr, "areascale" )==0 ) areascale = atof( val );        
	else if( stricmp( attr, "color" )==0 ) strcpy( color, val );
	else if( stricmp( attr, "legendlabel" )==0 || stricmp( attr, "label" )==0 ) strcpy( leglabel, lineval );
	else if( stricmp( attr, "labelfield" )==0 ) lblfld = fref( val );
	else if( stricmp( attr, "labeldetails" )==0 ) strcpy( lbldet, lineval );
	else if( stricmp( attr, "density" )==0 ) densfact = atof( val );
	else if( stricmp( attr, "outline" )==0 ) strcpy( outline, lineval );
	else if( stricmp( attr, "dotsize" )==0 ) ofs = atof( val );

	else if( stricmp( attr, "areafld" )==0 ) { areafld = fref( val ); datadriven = 1; }
	else if( stricmp( attr, "xfld" )==0 ) xfld = fref( val );
	else if( stricmp( attr, "colorfld" )==0 ) clrfld = fref( val );
	else if( stricmp( attr, "yloc" )==0 ) yloc = atof( val );
 	else if( stricmp( attr, "solidfill" )==0 ) {
                if( strnicmp( val, YESANS, 1 )==0 ) solidfill = 1;
                else solidfill = 0;
                }


	else Eerr( 1, "attribute not recognized", attr );
	}


/* sanity checks.. */
if( !datadriven ) {
	if( cenx < 0.0 || ceny < 0.0 || area < 0.0 ) return( Eerr( 428, "The attributes x, y, and area must all be specified", "" ) );
	}

if( datadriven && !scalebeenset() ) return( Eerr( 51, "datadriven requires scaled units.. no scaled plotting area has been defined yet w/ proc areadef", "" ));

/* overrides.. */
if( solidfill ) densfact = 0.0;

if( datadriven ) {
	ceny = Ea( Y, yloc );
	for( irow = 0; irow < Nrecords; irow++ ) {
		area = atof( da( irow, areafld-1 ) );
		area *= areascale;
		if( area > 50.0 ) { Eerr( 72405, "skipping a very large disk", da( irow, areafld ) ); continue; }
		radius = sqrt( area / PI );

		if( xfld > 0 ) cenx = Ea( X, fda( irow, xfld-1, X ));
		else cenx = Ea( X, (double)(irow+1) );

		if( clrfld > 0 ) strcpy( color, da( irow, clrfld-1 ));
		y = ceny + radius;  /* so all disk bottoms are on the line.. */
		do_disk( cenx, y, radius, color, densfact, ofs, outline, solidfill );
		if( lblfld > 0 ) {
			double labx, laby;
			textdet( "labeldetails", lbldet, &align, &adjx, &adjy, -2, "R", 1.0 );
			if( align == '?' ) align = 'C';
			labx = cenx+adjx;
			laby = (Elimit( Y, 'l', 'a' )-(Ecurtextheight*2.0))+adjy;
			Emov( labx, laby );
			Edotext( da( irow, lblfld-1 ), align );
			}
		}
	}

else	{   /* individual disks */
	
	/* now do the plotting work.. */
	/* convert area to a radius in inches.. */
	area *= areascale;
	if( area > 50.0 ) return( Eerr( 72405, "disk area is too large.. reduce 'area' or reduce 'areascale'", "" ) );
	
	radius = sqrt( area / PI );
	if( PLS.usingcm ) { cenx /= 2.54; ceny /= 2.54; ofs /= 2.54; radius /= 2.54; }
	
	if( botflag ) ceny += radius;
	
	do_disk( cenx, ceny, radius, color, densfact, ofs, outline, solidfill );
	
	if( leglabel[0] != '\0' ) PL_add_legent( LEGEND_COLOR, leglabel, "", color, "", "" );
	}

return( 0 );
}
Exemple #4
0
int
PLP_areadef()
{
int i;
char attr[NAMEMAXLEN], val[256];
char *line, *lineval;
int nt, lvp;
int first;

int stat;
double xlo, xhi, ylo, yhi;
char areaname[NAMEMAXLEN];
char xscaletype[50], yscaletype[50];
char title[256];
char title2[256];
char titledet[256];
char title2det[256];
char frame[256];
int nlines, maxlen;
int doframe;
int namedarea;
int align;
double adjx, adjy;
int gotarea, gotxrange, gotyrange;
int doxaxis, doyaxis;
char areacolor[COLORLEN];
char xminstr[256], xmaxstr[120];  /* was xminstr[120]  - needs bigger if big autorange datafield list given - scg 10/25/04 */
char yminstr[256], ymaxstr[120];  /* was yminstr[120]  -  '' - scg 10/25/04 */
double height, width;
int locspec;
char linebottom[256];
char lineside[256];
double autowf, autowmin, autowmax;
double autohf, autohmin, autohmax;
char mapurl[MAXPATH];
double cmadj;
int docats;
char maplabel[MAXTT];
int clickmap_on;

TDH_errprog( "pl proc areadef" );
 

/* initialize */
strcpy( xscaletype, "linear" );
strcpy( yscaletype, "linear" );
strcpy( areaname, "standard" );
gotxrange = gotyrange = 0;
if( PLS.device == 'c' || PLS.device == 'p' ) strcpy( areaname, "standardp" ); /* for sheet of paper */
strcpy( title, "" );
strcpy( title2, "" );
doframe = 0;
strcpy( frame, "" );
strcpy( titledet, "" );
strcpy( title2det, "" );
namedarea = 1;
/* doxaxis = doyaxis = 1; */
doxaxis = doyaxis = 0;
strcpy( areacolor, "" );
strcpy( PL_bigbuf, "" );
height = 4.0;
width = 6.0;
xlo = 1.5;
ylo = 5.0;
locspec = 0; 
strcpy( xminstr, "" );
strcpy( xmaxstr, "" );
strcpy( yminstr, "" );
strcpy( ymaxstr, "" );
strcpy( linebottom, "" );
strcpy( lineside, "" );
gotarea = 1;
autowf = 0.0; autowmin = 0.0; autowmax = 20.0;
autohf = 0.0; autohmin = 0.0; autohmax = 20.0;
strcpy( mapurl, "" );
strcpy( maplabel, "" );
docats = 0;
clickmap_on = 0;



/* get attributes.. */
first = 1;
while( 1 ) {
	line = getnextattr( first, attr, val, &lvp, &nt );
	if( line == NULL ) break;
	first = 0;
	lineval = &line[lvp];


	if( stricmp( attr, "areaname" )==0 ) {
		strcpy( areaname, val );
		gotarea = 1;
		}
	else if( stricmp( attr, "rectangle" )==0 ) {
		stat = getbox( "rectangle", lineval, &xlo, &ylo, &xhi, &yhi );
		if( stat ) { PLS.skipout = 1; return( 1 ); }
		namedarea = 0;
		gotarea = 1;
		}
	else if( stricmp( attr, "box" )==0 ) {
		sscanf( lineval, "%lf %lf", &width, &height );
		if( PLS.usingcm ) { width /= 2.54; height /= 2.54; }
		namedarea = 0;
		gotarea = 1;
		}	

	else if( stricmp( attr, "location" )==0 ) {
		sscanf( lineval, "%lf %lf", &xlo, &ylo );
		if( PLS.usingcm ) { xlo /= 2.54; ylo /= 2.54; }
		locspec = 1;
		}	

	else if( stricmp( attr, "autowidth" )==0 ) {
		nt = sscanf( lineval, "%lf %lf %lf", &autowf, &autowmin, &autowmax );
		}
		
	else if( stricmp( attr, "autoheight" )==0 ) {
		nt = sscanf( lineval, "%lf %lf %lf", &autohf, &autohmin, &autohmax );
		}

	else if( stricmp( attr, "xrange" )==0 || stricmp( attr, "xautorange" )==0 ) {
		if( strnicmp( val, "datafield", 9 )==0 ) strcpy( xminstr, lineval );
		else if( stricmp( val, "categories" )==0 ) { strcpy( xscaletype, val ); continue; }
		else	{
			nt = sscanf( lineval, "%s %s", xminstr, xmaxstr );
			if( nt != 2 ) {
				PLS.skipout = 1;
				return( Eerr( 105, "both min and max expected", "xrange" ));
				}
			}
		gotxrange = 1;
		}
	else if( stricmp( attr, "yrange" )==0 || stricmp( attr, "yautorange" )==0 ) {
		if( strnicmp( val, "datafield", 9 )==0 ) strcpy( yminstr, lineval );
		else if( stricmp( val, "categories" )==0 ) { strcpy( yscaletype, val ); continue; }
		else	{
			nt = sscanf( lineval, "%s %s", yminstr, ymaxstr );
			if( nt != 2 ) {
				PLS.skipout = 1;
				return( Eerr( 105, "both min and max expected", "yrange" ));
				}
			}
		gotyrange = 1;
		}

	else if( stricmp( attr, "xscaletype" )==0 ) strcpy( xscaletype, lineval );
	else if( stricmp( attr, "yscaletype" )==0 ) strcpy( yscaletype, lineval );

	else if( stricmp( attr, "frame" )==0 ) {
		if( strnicmp( val, "no", 2 )==0 ) doframe = 0;
		else { strcpy( frame, lineval ); doframe = 1; }
		}
	else if( stricmp( attr, "title" )==0 ) {
		strcpy( title, lineval );
		convertnl( title );
		}
	else if( stricmp( attr, "title2" )==0 ) {
		strcpy( title2, lineval );
		convertnl( title2 );
		}
	else if( stricmp( attr, "titledetails" )==0 ) strcpy( titledet, lineval );
	else if( stricmp( attr, "title2details" )==0 ) strcpy( title2det, lineval );
	else if( stricmp( attr, "areacolor" )==0 ) strcpy( areacolor, val );
	else if( stricmp( attr, "linebottom" )==0 ) {
		if( strnicmp( val, "no", 2 )!=0 ) strcpy( linebottom, lineval );
		}
	else if( stricmp( attr, "lineside" )==0 ) {
		if( strnicmp( val, "no", 2 )!= 0 ) strcpy( lineside, lineval );
		}

	else if( stricmp( attr, "clickmapurl" )==0 ) {
		if( PLS.clickmap ) { strcpy( mapurl, val ); clickmap_on = 1 ; }
		}
	else if( stricmp( attr, "clickmaplabel" )==0 ) {
		if( PLS.clickmap ) { strcpy( maplabel, lineval ); clickmap_on = 1 ; }
		}
        else if( stricmp( attr, "clickmaplabeltext" )==0 ) {
                if( PLS.clickmap ) { getmultiline( "clickmaplabeltext", lineval, MAXTT, maplabel ); clickmap_on = 1; }
                }

	else if( stricmp( attr, "axes" )==0 ) {
		if( stricmp( val, "none" )==0 ) { doxaxis = 0; doyaxis = 0; }
		else if( stricmp( val, "x" )==0 ) doxaxis = 1;
		else if( stricmp( val, "y" )==0 ) doyaxis = 1;
		else if( stricmp( val, "both" )==0 ) { doxaxis = 1; doyaxis = 1; }
		}
	else if( GL_slmember( attr, "?axis.stubs ?axis.selflocatingstubs" )) {
		if( strnicmp( attr, "xaxis.", 6 )==0 ) doxaxis = 1; 
		if( strnicmp( attr, "yaxis.", 6 )==0 ) doyaxis = 1; 
		if( GL_slmember( val, "none inc* dat*matic file datafield* list categories usecategories" )) ;
		else getmultiline( "stubtext", lineval, MAXBIGBUF-5, PL_bigbuf ); /* just to skip past it..*/
		}
	else if( strnicmp( attr, "xaxis.", 6 )==0 ) { doxaxis = 1; continue; }
	else if( strnicmp( attr, "yaxis.", 6 )==0 ) { doyaxis = 1; continue; }
	else if( GL_slmember( attr, "axisline tic* minortic*" )) continue;

	else if( GL_slmember( attr, "?categories ?extracategory catcompmethod" )) {
		docats = 1;
		if( GL_slmember( attr, "?categories" ) && strnicmp( val, "datafield", 9 )!=0 ) 
				getmultiline( "categories", lineval, MAXBIGBUF-5, PL_bigbuf ); /* skip over it.. */
		if( attr[0] == 'x' ) strcpy( xscaletype, "categories" );
		if( attr[0] == 'y' ) strcpy( yscaletype, "categories" );
		}

	else Eerr( 1, "areadef attribute not recognized", attr );
	}




/* now do the plotting work.. */

PL_resetstacklist();  /* (obscure) - reset the bar graph list that tries to
			keep track of fields for automatic stacking */

/* go set up category sets if needed.. */
if( docats ) {
	PLP_categories(); 
	TDH_errprog( "pl proc areadef" );
	}

if( stricmp( xscaletype, "categories" )==0 ) {
	if( PL_ncats('x') < 1 ) { 
		PLS.skipout = 1; 
		return( Eerr( 5972, "no x categories exist", "" ) ); 
		}
	gotxrange = 1;  /* note- categories could have been filled from a previous data set */
	strcpy( xminstr, "0" );
	sprintf( xmaxstr, "%d", PL_ncats('x')+1 );
	}

if( stricmp( yscaletype, "categories" )==0 ) {
	if( PL_ncats('y') < 1 ) { 
		PLS.skipout = 1; 
		return( Eerr( 5973, "no y categories exist", "" ) ); 
		}
	gotyrange = 1; /* note- categories could have been filled from a previous data set */
	strcpy( yminstr, "0" );
	sprintf( ymaxstr, "%d", PL_ncats('y')+1 );
	}

if( locspec ) { /* location and box specified, calculate xhi and yhi.. */
	xhi = xlo + width;
	yhi = ylo + height;
	}

/* determine area.. */
if( namedarea ) {
	RETRY:
	strcat( areaname, " " );
	for( i = 0; i < nareas; i++ ) {
		if( strnicmp( areas[i], areaname, strlen( areaname ) )==0 ) {
			if( Ecurpaper == 0 ) sscanf( areas[i], "%*s %lf %lf %lf %lf", &xlo, &ylo, &xhi, &yhi );
			else if( Ecurpaper == 1 ) sscanf( areas[i], "%*s %*s %*s %*s %*s %lf %lf %lf %lf", &xlo, &ylo, &xhi, &yhi );
			break;
			}
		}
	if( i == nareas ) {
		areaname[ strlen( areaname ) -1 ] = '\0';
		Eerr( 110, "warning, areaname not recognized, using 'standard'..", areaname );
		strcpy( areaname, "standard" );
		goto RETRY;
		}
	}
		
if( !gotarea && !locspec ) {  /* && !locspec added scg 11/21/00 */
	PLS.skipout = 1;
	return( Eerr( 130, "No plotting area has been specified", "" ) );
	}
if( !gotxrange ) {
	PLS.skipout = 1;
	return( Eerr( 130, "No xrange has been specified", "" ) );
	}
if( !gotyrange ) {
	PLS.skipout = 1;
	return( Eerr( 130, "No yrange has been specified", "" ) );
	}

/* set scaling type and special units if any.. */
stat = Escaletype( xscaletype, 'x' );
if( stat != 0 ) Escaletype( "linear", 'x' );
if( strnicmp( xscaletype, "log", 3 )==0 ) Esetunits( 'x', "linear" );
else Esetunits( 'x', xscaletype );

stat = Escaletype( yscaletype, 'y' );
if( stat != 0 ) Escaletype( "linear", 'y' );
if( strnicmp( yscaletype, "log", 3 )==0 ) Esetunits( 'y', "linear" );
else Esetunits( 'y', yscaletype );


/* if autoranging is specified, do it now.. */
if( strnicmp( xminstr, "datafield", 9 ) == 0 ) PLP_autorange( 'x', xminstr, xminstr, xmaxstr );
if( strnicmp( yminstr, "datafield", 9 ) == 0 ) PLP_autorange( 'y', yminstr, yminstr, ymaxstr );

/* if scaletype is log but there are data values = 0.0, go to log+1 scaling.. */
if( stricmp( xscaletype, "log" )==0 && atof( xminstr ) <= 0.0 ) Escaletype( "log+1", 'x' );
if( stricmp( yscaletype, "log" )==0 && atof( yminstr ) <= 0.0 ) Escaletype( "log+1", 'y' );

/* if using autowidth or autoheight, revise plotting area now.. */
if( autowf != 0.0 ) {
	double xmin, xmax;
	if( stricmp( xscaletype, "categories" )== 0 ) { 
		xmin = atof( xminstr );
		xmax = atof( xmaxstr );
		}
	else	{
		xmin = Econv( 'x', xminstr );
		xmax = Econv( 'x', xmaxstr );
		}
	xhi = xlo + ((xmax-xmin) * autowf);
	if( xhi - xlo < autowmin ) xhi = xlo + autowmin;
	else if( xhi - xlo > autowmax ) xhi = xlo + autowmax;
	}
if( autohf != 0.0 ) {
	double ymin, ymax;
	if( stricmp( yscaletype, "categories" )== 0 ) {
		ymin = atof( yminstr );
		ymax = atof( ymaxstr );
		}
	else	{
		ymin = Econv( 'y', yminstr );
		ymax = Econv( 'y', ymaxstr );
		}
	yhi = ylo + ((ymax-ymin) * autohf);
	if( yhi - ylo < autohmin ) yhi = ylo + autohmin;
	else if( yhi - ylo > autohmax ) yhi = ylo + autohmax;
	}

	


/* set the scaling for the plot area.. */
stat = Esetscale( 'x', xlo, xhi, xminstr, xmaxstr );
stat += Esetscale( 'y', ylo, yhi, yminstr, ymaxstr );

if( PLS.debug ) fprintf( PLS.diagfp, "areadef: lowerleft: %g,%g  upperright: %g,%g\n",
		xlo, ylo, xhi, yhi );
if( PLS.debug ) fprintf( PLS.diagfp, "areadef:   xrange is %s to %s.   yrange is %s to %s.\n",
		xminstr, xmaxstr, yminstr, ymaxstr );

if( stat != 0 ) return( stat );
	
DT_suppress_twin_warn( 0 );


/* set variables to hold plot area bounds and scale min/max.. */
if( PLS.usingcm ) cmadj = 2.54;
else cmadj = 1.0;
setfloatvar( "AREATOP", EYhi * cmadj );
setfloatvar( "AREABOTTOM", EYlo * cmadj );
setfloatvar( "AREALEFT", EXlo * cmadj );
setfloatvar( "AREARIGHT", EXhi * cmadj );
setcharvar( "XMIN", xminstr );
setcharvar( "XMAX", xmaxstr );
setcharvar( "YMIN", yminstr );
setcharvar( "YMAX", ymaxstr );


if( areacolor[0] != '\0' ) Ecblock( EXlo, EYlo, EXhi, EYhi, areacolor, 0 );
if( clickmap_on ) {
	if( GL_slmember( mapurl, "*@XVAL*" ) || GL_slmember( mapurl, "*@YVAL*" )) clickmap_seturlt( mapurl );
	else clickmap_entry( 'r', mapurl, 0, EXlo, EYlo, EXhi, EYhi, 0, 0, maplabel );
	}

/* draw a frame of the graphics area */
if( doframe ) {
	if( stricmp( frame, "bevel" )==0 ) {
		Ecblockdress( EXlo, EYlo, EXhi, EYhi, 0.1, "0.6", "0.8", 0.0, "" );
		}
	else	{
		linedet( "frame", frame, 1.0 );
		Ecblock( EXlo, EYlo, EXhi, EYhi, "", 1 );
		}
	}



/* draw bottom line */
if( linebottom[0] != '\0' ) {
	linedet( "linebottom", linebottom, 1.0 );
	Emov( EXlo, EYlo );
	Elin( EXhi, EYlo );
	}

/* draw side line */
if( lineside[0] != '\0' ) {
	linedet( "lineside", lineside, 1.0 );
	Emov( EXlo, EYlo );
	Elin( EXlo, EYhi );
	}

/* title */
if( title[0] != '\0' ) {
	textdet( "titledetails", titledet, &align, &adjx, &adjy, 0, "R", 1.0 );
	measuretext( title, &nlines, &maxlen );
	if( align == '?' ) align = 'L';
	if( align == 'L' ) Emov( EXlo + adjx, 
				EYhi + ((nlines-1) * Ecurtextheight ) + adjy + 0.02 );
	else if( align == 'C' ) 
		Emov( EXlo+((EXhi-EXlo) / 2.0 ) + adjx, 
			EYhi + ((nlines-1) * Ecurtextheight ) +adjy + 0.02 );
	else if( align == 'R' ) 
		Emov( EXhi + adjx, EYhi + ((nlines-1) * Ecurtextheight ) +adjy + 0.02);
	Edotext( title, align );
	}
/* title 2 */
if( title2[0] != '\0' ) {
	textdet( "title2details", title2det, &align, &adjx, &adjy, 0, "R", 1.0 );
	measuretext( title2, &nlines, &maxlen );
	if( align == '?' ) align = 'L';
	if( align == 'L' ) Emov( EXlo + adjx, 
		EYhi + ((nlines-1) * Ecurtextheight ) + adjy + 0.02 );
	else if( align == 'C' ) 
		Emov( EXlo+((EXhi-EXlo) / 2.0 ) + adjx, 
			EYhi + ((nlines-1) * Ecurtextheight ) +adjy + 0.02 );
	else if( align == 'R' ) Emov( EXhi + adjx, 
		EYhi + ((nlines-1) * Ecurtextheight ) +adjy + 0.02 );
	Edotext( title2, align );
	}


if( doxaxis ) PLP_axis( 'x', 6 );

if( doyaxis ) PLP_axis( 'y', 6 );

return( 0 );
}
Exemple #5
0
int
PLP_scatterplot()
{
int i;
char attr[NAMEMAXLEN], val[256];
char *line, *lineval;
int nt, lvp;
int first;

int stat;
int align;
double adjx, adjy;

int xfield, yfield;
char symbol[256];
double linelen;
char linedetails[256];
double xloc, yloc;
int cluster;
double radius;
char symcode[80];
double x, y;
char text[256];
double cx, cy;
double hlinelen;
char textdetails[256];
int lblfield;
char selex[256];
int result;
double sizescale;
int sizefield;
double ox[38], oy[38];
double clusterfact;
double oldx, oldy;
int dupcount;
int subdupcount;
int clustevery;
int verttext;
int nrow;
char legendlabel[256]; /* raised (can contain urls for clickmap) scg 4/22/04 */
char xrange[80], yrange[80];
double xlo, xhi, ylo, yhi;
char rhi[40], rlo[40];
double clusterdiff;
int realrow;
int clustermeth;
int symfield;
int symfield_userange;
int dupsleg;
char mapurl[MAXPATH], expurl[MAXPATH];
char maplabel[MAXTT], explabel[MAXTT];
int irow;
double ptx, pty;
double hw, txhi;
char linedir, reqlinedir;
double rectw, recth;
int dorect, rectoutline;
int clickmap_on;
int flop2;
int maxdups;
char labelword[80], labeltxt[80];
double vennden;

TDH_errprog( "pl proc scatterplot" );


/* initialize */
xfield = -1; yfield = -1;
strcpy( symbol, "" );
linelen = -1.0;
strcpy( linedetails, "" );
xloc = 0.0;
yloc = 0.0;
/* cluster = 1; */
cluster = 0;   /* changed and added to "breakers" in docs, scg 5/29/06 */
strcpy( text, "" );
strcpy( textdetails, "" );
lblfield = -1;
strcpy( selex, "" );
sizefield = -1;
sizescale = 0.5/72.0; /* correspond roughly with pt size */
clusterfact = 0.01;
verttext = 0;
strcpy( legendlabel, "" );
strcpy( xrange, "" );
strcpy( yrange, "" );
clustevery = 0;
clusterdiff = 0.001;
clustermeth = 0;
symfield = -1;
dupsleg = 0;
symfield_userange = 0;
strcpy( mapurl, "" ); strcpy( expurl, "" );
strcpy( maplabel, "" ); strcpy( explabel, "" );
dorect = 0;
rectoutline = 0;
linedir = reqlinedir = '\0'; /* scg 3/4/03 */
clickmap_on = 0;
strcpy( labelword, "@VAL" );
vennden = 0.0;

/* get attributes.. */
first = 1;
while( 1 ) {
	line = getnextattr( first, attr, val, &lvp, &nt );
	if( line == NULL ) break;
	first = 0;
	lineval = &line[lvp];

	if( stricmp( attr, "xfield" )==0 ) xfield = fref( val ) -1;
		
	else if( stricmp( attr, "yfield" )==0 ) yfield = fref( val ) -1;
	else if( stricmp( attr, "labelfield" )==0 ) lblfield = fref( val ) -1;
		
	else if( stricmp( attr, "symbol" )==0 ) strcpy( symbol, lineval );
	else if( stricmp( attr, "text" )==0 ) strcpy( text, val );
	else if( stricmp( attr, "textdetails" )==0 ) strcpy( textdetails, lineval );

	else if( stricmp( attr, "sizefield" )==0 ) sizefield = fref( val ) -1;
	else if( stricmp( attr, "sizescale" )==0 ) sizescale = atof( val ) * 0.5/72.0;
	else if( stricmp( attr, "xrange" )==0 ) strcpy( xrange, lineval );
	else if( stricmp( attr, "yrange" )==0 ) strcpy( yrange, lineval );
	else if( stricmp( attr, "clickmapurl" )==0 ) {
		if( PLS.clickmap ) { strcpy( mapurl, val ); clickmap_on = 1; }
		}
	else if( stricmp( attr, "clickmaplabel" )==0 ) {
		if( PLS.clickmap ) { strcpy( maplabel, lineval ); clickmap_on = 1; }
		}
        else if( stricmp( attr, "clickmaplabeltext" )==0 ) {
                if( PLS.clickmap ) { getmultiline( "clickmaplabeltext", lineval, MAXTT, maplabel ); clickmap_on = 1; }
                }

	else if( stricmp( attr, "linelen" )==0 ) {
		if( val[0] == '\0' ) linelen = -1.0;
		else	{
			linelen = atof( val );
			if( PLS.usingcm ) linelen /= 2.54;
			}
		}
	else if( stricmp( attr, "linedir" )==0 ) reqlinedir = tolower( val[0] );
	else if( stricmp( attr, "linedetails" )==0 ) strcpy( linedetails, lineval );
		
	else if( stricmp( attr, "xlocation" )==0 ) {
		Eposex( lineval, X, &xloc ); /* val -> lineval scg 5/3/99 */
		if( Econv_error() ) Eerr( 2394, "invalid xlocation", val );
		}
		
	else if( stricmp( attr, "ylocation" )==0 ) {
		Eposex( lineval, Y, &yloc ); /* val -> lineval 5/3/99 */
		if( Econv_error() ) Eerr( 2395, "invalid ylocation", val );
		}
		
	else if( stricmp( attr, "select" )==0 ) strcpy( selex, lineval );
	else if( stricmp( attr, "legendlabel" )==0 ) strcpy( legendlabel, lineval );

	else if( stricmp( attr, "cluster" )==0 ) {
		if( strnicmp( val, YESANS, 1 )==0 ) cluster = 1;
		else cluster = 0;
		}
	else if( stricmp( attr, "clusterdiff" )==0 ) {
		cluster = 1;
		clusterdiff = atof( val );
		}
	else if( stricmp( attr, "clustermethod" )==0 ) {
		cluster = 1;
		clustermeth = tolower( val[0] );  /* h, v, 2, u, r, ..  */
		}
	else if( stricmp( attr, "clusterfact" )==0 ) {
		cluster = 1;
		clusterfact = atof( val ) * .01;
		}
	else if( stricmp( attr, "clustevery" )==0 ) {
		cluster = 1;
		clustevery = atoi( val );
		if( clustevery < 1 ) clustevery = 1;
		}
	else if( stricmp( attr, "dupsleg" )==0 ) {
		if( strnicmp( val, YESANS, 1 )==0 ) { 
			dupsleg = 1; 
			cluster = 1; 
			clustermeth = 'l';
			strcpy( symbol, "sym6a" ); /* just to get us into symbol mode */
			}
		else dupsleg = 0;
		}
	else if( stricmp( attr, "symfield" )==0 ) {
		strcpy( symbol, "sym6a" ); /* just to get us into symbol mode */
		symfield = fref( val ) -1;
		symfield_userange = 0;
		}
	else if( stricmp( attr, "symrangefield" )==0 ) {
		strcpy( symbol, "sym6a" ); /* just to get us into symbol mode */
		symfield = fref( val ) -1;
		symfield_userange = 1;
		}
	else if( stricmp( attr, "verticaltext" )==0 ) {
		if( strnicmp( val, YESANS, 1 )==0 ) verttext = 1;
		else verttext = 0;
		}
	else if( stricmp( attr, "rectangle" )==0 ) {
		nt = sscanf( lineval, "%lf %lf %s", &rectw, &recth, val );
		if( nt == 3 ) rectoutline = 1;
		rectw *= 0.5;
		recth *= 0.5;
		rectw = Eax( rectw ) - Eax( 0.0 );
		recth = Eay( recth ) - Eay( 0.0 );
		dorect = 1;
		}

	else if( stricmp( attr, "labelword" ) == 0 ) strcpy( labelword, lineval );
	else if( stricmp( attr, "vennden" ) == 0 ) vennden = atof( val );

	else Eerr( 1, "attribute not recognized", attr );
	}


/* overrides and degenerate cases */
/* -------------------------- */
if( Nrecords < 1 ) return( Eerr( 17, "No data has been read yet w/ proc getdata", "" ) );
if( !scalebeenset() )
         return( Eerr( 51, "No scaled plotting area has been defined yet w/ proc areadef", "" ) );

if( xfield < 0 && yfield < 0 ) return( Eerr( 2205, "Niether xfield nor yfield defined", "" ));

if( lblfield >= 0 ) cluster = 0;  /* added scg 12/21/00 */

if( stricmp( legendlabel, "#usexname" )==0 ) getfname( xfield+1, legendlabel );
if( stricmp( legendlabel, "#useyname" )==0 ) getfname( yfield+1, legendlabel );

if( dorect ) strcpy( symbol, "" );


/* now do the plotting work.. */
/* -------------------------- */

if( cluster ) {
	/* make offsets */
	for( i = 0; i < 38; i++ ) {
		ox[i] = xofst[i] * clusterfact;
		oy[i] = yofst[i] * clusterfact;
		}

	/* determine cluster method */
	if( clustermeth == 0 ) {
		if( yfield < 0 ) clustermeth = 'v'; 	 /* 1-d horizontal - cluster vertically (was 'h'-scg 4/21/05) */
		else if( xfield < 0 ) clustermeth = 'h'; /* 1-d vertical - cluster horizontally (was 'v'-scg 4/21/05) */
		else clustermeth = '2'; 		 /* 2-d cluster */
		}
	}

/* ranges */
xlo = EDXlo;
xhi = EDXhi;
ylo = EDYlo;
yhi = EDYhi;
if( xrange[0] != '\0' ) {
	nt = sscanf( xrange, "%s %s", rlo, rhi );
	xlo = Econv( X, rlo );
	if( Econv_error() ) { Eerr( 3958, "xrange bad format", rlo ); xlo = EDXlo; }
	if( nt == 2 ) xhi = Econv( X, rhi );
	if( Econv_error() ) { Eerr( 3958, "xrange bad format", rhi ); xhi = EDXhi; }
	}
if( yrange[0] != '\0' ) {
	nt = sscanf( yrange, "%s %s", rlo, rhi );
	ylo = Econv( Y, rlo );
	if( Econv_error() ) { Eerr( 3958, "yrange bad format", rlo ); ylo = EDYlo; }
	if( nt == 2 ) yhi = Econv( Y, rhi );
	if( Econv_error() ) { Eerr( 3958, "yrange bad format", rhi ); yhi = EDYhi; }
	}






nrow = 0;
for( i = 0; i < Nrecords; i++ ) {

	if( selex[0] != '\0' ) { /* process against selection condition if any.. */
                stat = do_select( selex, i, &result );
                if( stat != 0 ) { Eerr( stat, "Select error", selex ); continue; }
                if( result == 0 ) continue; /* reject */
                }

	/* get x value.. */
	if( xfield >= 0 ) {
		x = fda( i, xfield, 'x' );
        	if( Econv_error() ) { conv_msg( i, xfield, "xfield" ); continue; }
		if( x < xlo || x > xhi ) continue;
		}

	/* get y value.. */
	if( yfield >= 0 ) {
		y = fda( i, yfield, 'y' );
        	if( Econv_error() ) { conv_msg( i, yfield, "yfield" ); continue; }
		if( y < ylo || y > yhi ) continue;
		}

	/* go to absolute units.. */
	if( xfield < 0 ) x = xloc;
	else x = Eax(x);
	if( yfield < 0 ) y = yloc;
	else y = Eay(y);


	/* put (x,y) into PLV array so points can be sorted.. */
	if( nrow >= PLVthirdsize ) {
		fprintf( PLS.errfp, "point capacity exceeded, skipping data point (raise using -maxvector)\n" );
		continue;
		}
	dat3d( nrow, 0 ) = x;
	dat3d( nrow, 1 ) = y;
	dat3d( nrow, 2 ) = (double)i;  /* added scg 12/21/00 - went from dat2d to dat3d */
				       /* need to keep track of actual location in data array for labels, sizefield, etc.. */
	nrow++;
	}


/* if clustering and not using a label field, sort PLV array */
if( cluster && lblfield < 0 && sizefield < 0 ) {
	if( PLS.debug ) fprintf( PLS.diagfp, "sorting points for scatterplot\n" );
	qsort( PLV, nrow, sizeof(double)*3, ptcompare );
	}



if( verttext ) Etextdir( 90 );

/* these are used in clustering.. */
oldx = NEGHUGE;
oldy = NEGHUGE;
dupcount = 0;
subdupcount = 0;
maxdups = 0;

strcpy( symcode, "sym6a" );
radius = 0.04;


/* in the following, text must come before symbol.. */
if( text[0] != '\0' || lblfield >= 0 ) {
	textdet( "textdetails", textdetails, &align, &adjx, &adjy, -3, "R", 1.0 );
	}
if( symbol[0] != '\0' ) {
	symdet( "symbol", symbol, symcode, &radius );
	}
if( linelen > 0.0 || rectoutline ) {
	linedet( "linedetails", linedetails, 0.5 );
	}
cx = Ecurtextwidth * 0.3;
cy = Ecurtextheight * 0.3;
hlinelen = linelen * 0.5;
txhi = cy + cy;
if( text[0] != '\0' ) hw = strlen( text ) * Ecurtextwidth * 0.5;

/* now display points.. */
for( irow = 0; irow < nrow; irow++ ) {
	x = dat3d( irow, 0 );
	y = dat3d( irow, 1 );
	realrow = (int)dat3d( irow, 2 ); /* added scg 12/21/00 */

	/* in this loop, you MUST USE REALROW, NOT IROW for accessing ancillary data fields!! */

	if( cluster ) {
		if( GL_close_to( x, oldx, clusterdiff ) && GL_close_to( y, oldy, clusterdiff ) ) {
			subdupcount++;
			if( subdupcount >= clustevery ) {
				dupcount++;
				subdupcount = 0;
				}

			if( dupcount % 2 == 0 ) flop2 = 1;
			else flop2 = -1;

			if( clustermeth == '2' && dupcount > 37 ) {
				maxdups = 37;
				dupcount = 0; /* mod */
				}

			if( clustermeth == 'h' ) x += ((dupcount+1)/2) * clusterfact * 2.0 * flop2;
			else if( clustermeth == 'v' ) y += ((dupcount+1)/2) * clusterfact * 2.0 * flop2;
			else if( clustermeth == 'u' ) y += dupcount * clusterfact * 2.0; /* 1D upward */
			else if( clustermeth == 'r' ) x += dupcount * clusterfact * 2.0; /* 1D rightward */
			else if( clustermeth == 'l' ) ; /* legend lookup, no offset */
			else if( clustermeth == '2' ) {  x += ox[dupcount%38]; y += oy[dupcount%38]; } /* 2-D */

			if( clustermeth == 'l' ) { /* if more duplicate points coming, skip.. */
				if( irow < nrow-1 ) {
					double nextx, nexty;
					nextx = dat3d( irow+1, 0 );
					nexty = dat3d( irow+1, 1 );
					if( GL_close_to( x, nextx, clusterdiff ) && 
					    GL_close_to( y, nexty, clusterdiff ) ) continue;
					}
				}
			}
		else {
			if( dupcount > maxdups ) maxdups = dupcount;
			oldx = x;
			oldy = y;
			dupcount = 0;
			subdupcount = 0;
			}
		}

	/* allow @field substitutions into url */
        if( clickmap_on ) {
		do_subst( expurl, mapurl, realrow, URL_ENCODED );
		do_subst( explabel, maplabel, realrow, NORMAL );
		}



	/* render text, mark or line.. */
	/* text can be combined with mark if text and symbol both specified */

	/* symbol or rectangle.. */
	if( symbol[0] != '\0' || dorect || ( text[0] == '\0' && linelen <= 0.0 && lblfield < 0 ) ) {
		if( symfield >= 0 ) {  /* look it up in legend list.. */
			if( symfield_userange ) {
                		stat = PL_get_legent_rg( atof( da( realrow, symfield ) ), symbol, NULL, NULL );
				}
                	else stat = PL_get_legent( da( realrow, symfield ), symbol, NULL, NULL );
			if( stat ) Eerr( 7429, "warning: symfield: no matching legend entry tag found", da( realrow, symfield ) );
			if( !dorect ) symdet( "symfield", symbol, symcode, &radius );
			}
		if( dupsleg ) {  /* look it up in legend list.. */
                	stat = PL_get_legent_rg( (double)dupcount+1, symbol, NULL, NULL );
			if( stat ) Eerr( 7692, "warning: dupsleg: no appropriate legend entry tag\n", "" );
			if( !dorect ) symdet( "symfield", symbol, symcode, &radius );
			/* note: currently all marks will be rendered; the last one will be on "top"  */
			}
		if( sizefield >= 0 ) 
			radius = sqrt((atof( da( realrow, sizefield ) ) * sizescale)/3.1415927);
			         /* sizefield scales up the AREA of symbol, not the diameter */
		if( dorect ) {
			char color[ COLORLEN ];
			strcpy( color, "" ); /* added scg 9/1/05 - heatmap bug */
			if( symfield >=0 || dupsleg ) sscanf( symbol, "%s", color ); /* strip off any trailing space */
			Ecblock( x-rectw, y-recth, x+rectw, y+recth, color, rectoutline );
			symbol[0] = '\0';
			}
		else if( vennden > 0.0 ) {
			double urad;
			for( urad = 0.01; urad < radius; urad += vennden ) Emark( x, y, symcode, urad );
			} 
		else Emark( x, y, symcode, radius );

		if( clickmap_on ) {
			if( dorect ) clickmap_entry( 'r', expurl, 0, x-rectw, y-recth, x+rectw, y+recth, 0, 0, explabel );
			else clickmap_entry( 'r', expurl, 0, x-radius, y-radius, x+radius, y+radius, 0, 0, explabel );
			}
			
		}

	/* text */
	if( text[0] != '\0' ) {
		if( symbol[0] != '\0' )  /* set text color etc... */
			textdet( "textdetails", textdetails, &align, &adjx, &adjy, -3, "R", 1.0 );
		if( sizefield >= 0 ) Etextsize( (int) (atof( da( realrow, sizefield ) ) * sizescale) );
		if( verttext ) { ptx = (x+cy)+adjx; pty = y; } /* cy puts midheight of character on point */
		else { ptx = x+adjx; pty = (y-cy)+adjy; }

		convertnl( text );
		Emov( ptx, pty );
		if( align == '?' ) Edotext( text, 'C' );
		else Edotext( text, align );
		if( symbol[0] != '\0'  )  /* restore symbol color etc... */
			symdet( "symbol", symbol, symcode, &radius );

		if( clickmap_on ) clickmap_entry( 'r', expurl, 0, ptx-hw, pty, x+hw, y+txhi, 0, 0, explabel );
		}

	/* label from data */
	else if( lblfield  >= 0 ) {
		if( sizefield >= 0 ) Etextsize( (int) (atof( da( realrow, sizefield ) ) * sizescale) );
		if( verttext) { ptx = (x+cy)+adjx; pty = y+adjy; } /* cy puts midheight of character on point */
		else { ptx = x+adjx; pty = (y-cy)+adjy; } 

		strcpy( labeltxt, labelword );
		GL_varsub( labeltxt, "@VAL", da( realrow, lblfield ) );

		Emov( ptx, pty );
		if( align == '?' ) Edotext( labeltxt, 'C' );
		else Edotext( labeltxt, align );

		if( clickmap_on ) {
			hw = strlen( labeltxt ) * Ecurtextwidth * 0.5;
			if( GL_member( align, "C?" ))clickmap_entry( 'r', expurl, 0, ptx-hw, pty, x+hw, y+txhi, 0, 0, explabel );
			else if( align == 'L' ) clickmap_entry( 'r', expurl, 0, ptx, pty, x+(hw*2.0), y+txhi, 0, 0, explabel );
			else if( align == 'R' ) clickmap_entry( 'r', expurl, 0, ptx-(hw*2.0), pty, x, y+txhi, 0, 0, explabel );
			}
		}

	/* line */         /* (no clickmap support) */   /* no legend support either (?) */
	else if( linelen > 0.0 ) {
		if( sizefield >= 0 ) hlinelen = linelen * 0.5 * atof( da( realrow, sizefield ) ); 
					/* sizefield acts as a scale factor to linelen */

		if( reqlinedir != '\0' ) linedir = reqlinedir;
		else if( xfield >= 0 && yfield >= 0 ) linedir = 'h'; 	/* arbitrary .. scg 5/16/03 */
		else if( xfield >= 0 ) linedir = 'v';
		else linedir = 'h';			/* scg 3/5/03 */

		if( linedir == 'v' ) { Emov( x, y-hlinelen ); Elin( x, y+hlinelen ); }
		else if( linedir == 'u' ) { Emov( x, y ); Elin( x, y+(hlinelen*2.0) ); }
		else if( linedir == 'r' ) { Emov( x, y ); Elin( x+(hlinelen*2.0), y ); }
		else { Emov( x-hlinelen, y ); Elin( x+hlinelen, y ); }
		}

	}
if( verttext ) Etextdir( 0 );

if( legendlabel[0] != '\0' ) {
	char s[40];
	sprintf( s, "%d", nrow );
	GL_varsub( legendlabel, "@NVALUES", s );
	if( linelen <= 0.0 && lblfield < 0 && text[0] == '\0' )
		PL_add_legent( LEGEND_SYMBOL, legendlabel, "", symbol, "", "" );
	else if( symbol[0] != '\0' && text[0] != '\0' )
		PL_add_legent( LEGEND_SYMBOL+LEGEND_TEXT, legendlabel, "", text, textdetails, symbol );
	else if( linelen > 0.0 ) {
		char dirstr[8];
		sprintf( dirstr, "%c", linedir );
		PL_add_legent( LEGEND_LINEMARK, legendlabel, "", linedetails, dirstr, "" );
		}
	}

setintvar( "NVALUES", nrow );
maxdups++;
setintvar( "MAXDUPS", maxdups );

return( 0 );
}