101
100
double cmylast, cmemin, cmemax;
102
101
char cmemins[40], cmemaxs[40];
103
102
char cmvalfmt[80], cmtxt[100];
103
int logx, logy, stubexp;
105
char autodays[40], automonths[40];
106
char labelurl[256], labelinfo[256];
109
char firststub[80], laststub[80];
110
char stubsubpat[80], stubsubnew[80];
105
112
TDH_errprog( "pl proc axis" );
158
165
strcpy( cmemins, "min" ); strcpy( cmemaxs, "max" );
159
166
strcpy( cmvalfmt, "" );
167
stubexp = 0; stublen = 0;
168
strcpy( autodays, "" ); strcpy( automonths, "" );
169
strcpy( labelurl, "" ); strcpy( labelinfo, "" );
170
stubmult = 1.0; stubmininc = 0.0;
171
strcpy( firststub, "" ); strcpy( laststub, "" );
172
strcpy( stubsubpat, "" ); strcpy( stubsubnew, "" );
162
175
/* get attributes.. */
225
239
GL_getchunk( buf, lineval, &i, " \t" );
226
240
while( GL_member( lineval[i], " \t" ) ) i++;
227
strcpy( Bigbuf, &lineval[i] );
241
strcpy( PL_bigbuf, &lineval[i] );
242
convertnl( PL_bigbuf );
230
244
else if( stricmp( val, "none" )==0 ) isrc = 0;
233
247
if( stricmp( val, "text" ) == 0 ) {
234
getmultiline( "stubs", "", MAXBIGBUF, Bigbuf );
248
getmultiline( "stubs", "", MAXBIGBUF, PL_bigbuf );
238
252
"warning: proc axis assuming multiline stub text even though 'text' keyword not given\n" );
239
getmultiline( "stubs", lineval, MAXBIGBUF, Bigbuf );
253
getmultiline( "stubs", lineval, MAXBIGBUF, PL_bigbuf );
265
279
else if( stricmp( &attr[astart], "stubomit" )==0 ) strcpy( stubomit, lineval );
267
else if( stricmp( &attr[astart], "stubslide" )==0 ) Elenex( val, xory, &stubslide );
281
else if( stricmp( &attr[astart], "stubslide" )==0 ) Elenex( val, xory, &stubslide );
283
else if( stricmp( &attr[astart], "stubexp" )==0 ) {
284
if( strnicmp( val, YESANS, 1 )==0 ) stubexp = 1;
285
else if( stricmp( val, "exp-1" )==0 ) stubexp = 2;
289
else if( stricmp( &attr[astart], "stublen" )==0 ) stublen = atoi( val );
291
else if( stricmp( &attr[astart], "stubmult" )==0 ) stubmult = atof( val );
293
else if( stricmp( &attr[astart], "stubmininc" )==0 ) stubmininc = atof( val );
269
295
else if( stricmp( &attr[astart], "ticslide" )==0 ) Elenex( val, xory, &ticslide );
271
297
else if( stricmp( &attr[astart], "labeldetails" )==0 ) strcpy( axislabeldet, lineval );
273
299
else if( stricmp( &attr[astart], "labeldistance" )==0 ) {
274
300
axislabelofs = atof( val );
275
if( Using_cm ) axislabelofs /= 2.54;
301
if( PLS.usingcm ) axislabelofs /= 2.54;
278
304
else if( stricmp( &attr[astart], "location" )==0 ) {
341
367
else stubcull = 0.0;
344
else if( stricmp( &attr[astart], "autoyears" )==0 ) strcpy( autoyears, val );
370
else if( stricmp( &attr[astart], "autoyears" )==0 ) {
371
strcpy( autoyears, val );
372
if( stricmp( autoyears, "yes" )==0 || stricmp( autoyears, "y" )==0 ) strcpy( autoyears, "'yy" );
373
else if( stricmp( autoyears, "no" )==0 ) strcpy( autoyears, "" );
376
else if( stricmp( &attr[astart], "autodays" )==0 ) {
377
strcpy( autodays, val );
378
if( stricmp( autodays, "yes" )==0 || stricmp( autodays, "y" )==0 ) strcpy( autodays, "Mmmdd" );
379
else if( stricmp( autodays, "no" )==0 ) strcpy( autodays, "" );
382
else if( stricmp( &attr[astart], "automonths" )==0 ) {
383
strcpy( automonths, val );
384
if( stricmp( automonths, "yes" )==0 || stricmp( automonths, "y" )==0 ) strcpy( automonths, "Mmm" );
385
else if( stricmp( automonths, "no" )==0 ) strcpy( automonths, "" );
345
389
else if( stricmp( &attr[astart], "signreverse" )==0 ) {
346
390
if( strnicmp( val, YESANS, 1 )==0 )revsign = 1;
347
391
else revsign = 0;
349
394
else if( stricmp( &attr[astart], "stubevery" )==0 ) stubevery = atoi( val );
396
else if( stricmp( &attr[astart], "firststub" )==0 ) {
397
strcpy( firststub, lineval );
398
if( strcmp( firststub, "\"\"" )==0 ) strcpy( firststub, " " );
400
else if( stricmp( &attr[astart], "laststub" )==0 ) {
401
strcpy( laststub, lineval );
402
if( strcmp( laststub, "\"\"" )==0 ) strcpy( laststub, " " );
404
else if( stricmp( &attr[astart], "stubsubpat" )==0 ) strcpy( stubsubpat, lineval );
405
else if( stricmp( &attr[astart], "stubsubnew" )==0 ) {
406
strcpy( stubsubnew, lineval );
407
if( strcmp( stubsubnew, "\"\"" )==0 ) strcpy( stubsubnew, " " );
350
410
else if( stricmp( &attr[astart], "clickmap" )==0 ) {
351
411
if( strnicmp( val, "xy", 2 )==0 ) {
352
412
if( xory == 'x' ) clickmap = 3;
377
437
if( stubevery == 0 ) stubevery = 1;
442
/* -------------------------- */
380
443
/* now do the plotting work.. */
381
444
/* -------------------------- */
382
446
Egetunits( xory, scaleunits );
384
448
/* do the label.. easier if we do it before the Eflip below.. */
385
449
if( axislabel[0] != '\0' ) {
450
double xpos, ypos, txtsize;
387
451
textdet( "labeldetails", axislabeldet, &align, &adjx, &adjy, 0, "R" );
452
txtsize = (double)(strlen( axislabel )) * Ecurtextwidth;
389
454
if( xory == 'x' ) {
390
Emov( (EXlo+ (( EXhi - EXlo ) / 2.0 )) + adjx, (pos - axislabelofs) + adjy );
455
xpos = ( EXlo+ (( EXhi - EXlo ) / 2.0 )) + adjx;
456
ypos = (pos - axislabelofs) + adjy;
391
458
Ecentext( axislabel );
459
if( PLS.clickmap && ( labelurl[0] != '\0' || labelinfo[0] != '\0' ) )
460
clickmap_entry( 'r', labelurl, 0, xpos - (txtsize/2.0), ypos,
461
xpos + (txtsize/2.0), ypos+Ecurtextheight, 1, 0, labelinfo );
393
463
else if( xory == 'y' ) {
395
Emov( (pos - axislabelofs) + adjx, (EYlo + (( EYhi-EYlo ) / 2.0 )) + adjy );
464
xpos = (pos - axislabelofs) + adjx;
465
ypos = (EYlo + (( EYhi-EYlo ) / 2.0 )) + adjy;
397
468
Ecentext( axislabel );
470
if( PLS.clickmap && ( labelurl[0] != '\0' || labelinfo[0] != '\0' ) )
471
clickmap_entry( 'r', labelurl, 0, xpos-Ecurtextheight, ypos - (txtsize*0.6),
472
xpos, ypos + (txtsize*0.6), 0, 0, labelinfo );
424
501
/* if doing Y axis with text stubs, and user didn't specify stubreverse: no,
425
502
reverse the stubs */
426
503
if( xory == 'y' && !stubreverse_given && stubreverse == 0 &&
427
( isrc == HERE || isrc == FROMFILE || isrc == FROMDATA ) ) {
504
( isrc == HERE || isrc == FROMFILE || isrc == FROMDATA ) && !selfloc ) { /* && !selfloc added scg 3/19/03 */
429
506
if( !stubrangegiven ) stubstop = max - 1.0;
432
510
if( stubformat[0] != '\0' && isrc == 0 )
433
511
Eerr( 2749, "warning, stubformat but no stubs specification", "" );
460
538
strcpy( minorticunits, "" );
461
539
minorticinc = minorticinc * 60;
463
else if( stricmp( scaleunits, "datetime" )==0 && strnicmp( minorticunits, "hour", 4 ) ==0 ) {
541
else if( stricmp( scaleunits, "datetime" )==0 &&
542
(strnicmp( minorticunits, "hour", 4 ) ==0 || strnicmp( minorticunits, "minute", 3 )==0 )) {
543
double winsize; /* window size in hours */
544
DT_getwin( &winsize );
464
545
strcpy( minorticunits, "" );
465
minorticinc = minorticinc / 24.0;
546
minorticinc = minorticinc / winsize;
547
if( strnicmp( minorticunits, "minute", 3 )==0 ) minorticinc = minorticinc / 60.0;
467
else if( stricmp( scaleunits, "time" )==0 && strnicmp( minorticunits, "second", 4 ) ==0 ) {
549
else if( stricmp( scaleunits, "time" )==0 && strnicmp( minorticunits, "second", 3 ) ==0 ) {
468
550
strcpy( minorticunits, "" );
469
551
minorticinc = minorticinc / 60.0;
579
/* --------------------------------- */
496
580
/* preliminaries based on stubs type */
497
581
/* --------------------------------- */
499
if( isrc == HERE ) bigbuflen = strlen( Bigbuf );
583
if( isrc == HERE ) bigbuflen = strlen( PL_bigbuf );
501
if( isrc == FROMFILE ) { /* if taking from file, read the file into Bigbuf */
585
if( isrc == FROMFILE ) { /* if taking from file, read the file into PL_bigbuf */
502
586
stubfp = fopen( filename, "r" );
503
587
if( stubfp == NULL ) {
504
588
Eerr( 303, "Cannot open specified stub file", filename );
540
620
strcpy( incunits, "" );
541
621
incamount = incamount * 60.0;
543
else if( stricmp( scaleunits, "datetime" )==0 && strnicmp( incunits, "hour", 4 ) ==0 ) {
544
strcpy( incunits, "" );
545
incamount = incamount / 24.0;
547
else if( stricmp( scaleunits, "time" )==0 && strnicmp( incunits, "second", 4 ) ==0 ) {
623
else if( stricmp( scaleunits, "datetime" )==0 &&
624
( strnicmp( incunits, "hour", 4 ) ==0 || strnicmp( incunits, "minute", 3 )==0 )) {
625
double winsize; /* window size in hours */
626
/* must be relative to window size.. */
627
DT_getwin( &winsize );
628
incamount = incamount / winsize;
629
if( strnicmp( incunits, "minute", 3 )==0 ) incamount = incamount / 60.0;
630
strcpy( incunits, "" );
631
/* incamount = incamount / 24.0; */
633
else if( stricmp( scaleunits, "datetime" )==0 && strnicmp( incunits, "minute", 3 ) ==0 ) {
634
strcpy( incunits, "" );
635
incamount = (incamount / 24.0) / 60.0;
637
else if( stricmp( scaleunits, "time" )==0 && strnicmp( incunits, "second", 3 ) ==0 ) {
548
638
strcpy( incunits, "" );
549
639
incamount = incamount / 60.0;
572
662
if( strnicmp( incunits, "month", 5 )==0 ) {
574
664
if( ! GL_smember( scaleunits, "date" ))
575
Eerr( 2476, "month increment only valid with date scale type", "" );
665
return( Eerr( 2476, "month increment only valid with date scale type", "" ) );
576
666
specialunits = MONTHS;
577
667
selfloc = 0; /* for rendering purposes don't treat month stubs as self locating.. */
578
668
/* do the following to get starting m, d, y.. */
611
703
if( xory == 'x' ) setfloatvar( "XINC", inc );
612
704
else if( xory == 'y' ) setfloatvar( "YINC", inc );
708
if( Escaletype_x == E_LOG || Escaletype_x == E_LOGPLUS1 ) logx = 1;
709
if( Escaletype_y == E_LOG || Escaletype_y == E_LOGPLUS1 ) logy = 1;
614
711
/* sanity check.. added scg 8/7/00 */
615
712
if( inc <= 0.0 ) return( Eerr( 2705, "axis increment is zero or negative", "" ));
718
/* ---------------------------------------------- */
617
719
/* render the stubs and/or tics and/or grid lines.. */
618
720
/* ---------------------------------------------- */
634
736
if( isrc == INCREMENTAL ) {
636
738
/* exception for log 0.0 */
637
if( y <= 0.0 && ((xory == 'x' && (Escaletype_x == E_LOG || Escaletype_x == E_LOGPLUS1 ) ) ||
638
(xory == 'y' && (Escaletype_y == E_LOG || Escaletype_y == E_LOGPLUS1 ) ) ) ) goto NEXTSTUB;
739
if( y <= 0.0 && ((xory == 'x' && logx ) || (xory == 'y' && logy ) ) ) goto NEXTSTUB;
642
743
if( isrc == INCREMENTAL ) {
643
double yy, fabs(), ftest;
744
double yy, fabs(), ftest, exp();
644
745
if( revsign && fabs(y) > 0.0001 ) yy = y * -1;
747
if( stubexp == 1 ) yy = exp( yy );
748
else if( stubexp == 2 ) yy = exp( yy ) - 1;
750
/* when generating incremental axes moving from negative to positive, for zero sprintf sometimes
751
gives -0.00 or very tiny values like -5.5579e-17. The following is a workaround.. scg 7/5/01 */
752
/* moved here from Euprint() scg 10/1/03 */
753
if( stubstart < 0.0 && stubstop > 0.0 && yy < 0.0000000000001 && yy > -0.0000000000001 ) yy = 0.0;
755
if( stubmult != 1.0 ) yy = yy * stubmult; /* added scg 10/2/03 */
646
757
nt = sscanf( incunits, "%lf", &ftest );
647
758
if( nt > 0 ) Euprint( txt, xory, yy/ftest, stubformat );
648
759
else Euprint( txt, xory, yy, stubformat );
649
if( Clickmap && clickmap ) Euprint( cmtxt, xory, yy, cmvalfmt );
760
if( PLS.clickmap && clickmap ) Euprint( cmtxt, xory, yy, cmvalfmt );
652
763
if( isrc == HERE || isrc == FROMFILE ) {
653
764
if( ibb >= bigbuflen ) break;
654
GL_getseg( txt, Bigbuf, &ibb, "\n" );
655
if( Clickmap && clickmap ) strcpy( cmtxt, txt );
765
GL_getseg( txt, PL_bigbuf, &ibb, "\n" );
766
if( PLS.clickmap && clickmap ) strcpy( cmtxt, txt );
658
769
if( isrc == FROMDATA ) {
659
if( irow >= Nrecords[Dsel] ) break;
770
if( irow >= Nrecords ) break;
660
771
if( ( irow % stubevery ) != 0 ) { irow++; goto NEXTSTUB; }
661
772
if( nstubdf == 1 )
662
773
sprintf( txt, "%s", da( irow, stubdf1 ) );
663
774
else if( nstubdf == 2 )
664
775
sprintf( txt, "%s %s", da( irow, stubdf1 ), da( irow, stubdf2 ) );
665
if( Clickmap && clickmap ) strcpy( cmtxt, txt );
776
if( PLS.clickmap && clickmap ) strcpy( cmtxt, txt );
669
780
if( isrc == FROMCATS ) {
670
if( irow >= Ncats[axslot] ) break;
781
char *catp, *PL_getcat();
782
catp = PL_getcat( xory, irow );
783
if( catp == NULL ) break; /* reached end of cat list */
671
784
if( ( irow % stubevery ) != 0 ) { irow++; goto NEXTSTUB; }
672
y = Econv( xory, Cats[axslot][irow] ); /* error checking not needed */
673
strcpy( txt, Cats[axslot][irow] );
674
if( Clickmap && clickmap ) strcpy( cmtxt, txt );
785
y = Econv( xory, catp ); /* error checking not needed */
787
if( PLS.clickmap && clickmap ) strcpy( cmtxt, txt );
682
795
y = Econv( xory, buf );
683
796
if( Econv_error() ) {
684
797
Eerr( 9675, "warning, error on date conversion", buf );
798
break; /* goto NEXTSTUB; changed to avoid inf loop - scg 2/12/03 */
687
800
if( day != 1 ) goto NEXTSTUB; /* added scg 9/12/01 */
688
801
if( ( y - stubstop ) > overrun ) break;
689
802
DT_formatdate( buf, stubformat, txt ); /* buf holds date string made above */
690
if( Clickmap && clickmap ) DT_formatdate( buf, cmvalfmt, cmtxt ); /* buf holds date string made above */
803
if( PLS.clickmap && clickmap ) DT_formatdate( buf, cmvalfmt, cmtxt ); /* buf holds date string made above */
691
805
if( autoyears[0] != '\0' && ( (firsttime && mon < 11) || mon == 1) ) { /* mon<11 added scg 9/12/01 */
693
806
if( strlen( autoyears ) == 2 ) sprintf( buf, "%s\n%02d", txt, yr % 100 );
694
807
else if( strlen( autoyears ) == 3 ) sprintf( buf, "%s\n'%02d", txt, yr % 100 );
818
if( autodays[0] != '\0' ) {
819
if( stricmp( scaleunits, "datetime" )!=0 ) Eerr( 9677, "warning, autodays is only valid with datetime scaling", "" );
821
double datepart, timepart;
823
datepart = floor( y );
824
timepart = y - datepart;
825
if( firsttime || fabs(timepart) < 0.000001 ) { /* render date */
826
DT_fromjul( (long)datepart, dt );
827
DT_formatdate( dt, autodays, buf );
834
/* automonths - can be used w/ date or datetime.. */
835
if( automonths[0] != '\0' ) {
839
DT_fromjul( (long) y, dt );
840
DT_jdate( dt, &foo ); /* to get m d y */
841
DT_getmdy( &imon, &iday, &iyr );
842
if( firsttime || iday == 1 ) {
843
DT_formatdate( dt, automonths, buf );
850
/* last minute stub content overrides.. */
851
if( stubsubpat[0] != '\0' && GL_wildcmp( txt, stubsubpat, strlen(stubsubpat), 0 )==0 ) strcpy( txt, stubsubnew );
852
if( firststub[0] != '\0' && firsttime ) strcpy( txt, firststub );
853
if( laststub[0] != '\0' && y+inc > stubstop ) strcpy( txt, laststub );
774
mapentry( 'r', cmtxt, clickmap, (Ea(Y,y)-halfdown)+stubslide, cmemin,
775
Ea(Y,y)+halfup+stubslide, cmemax, 0, 1 );
928
clickmap_entry( 'r', cmtxt, clickmap, (Ea(Y,y)-halfdown)+stubslide, cmemin,
929
Ea(Y,y)+halfup+stubslide, cmemax, 0, 1, "" );
778
mapentry( 'r', cmtxt, clickmap, cmemin, (Ea(Y,y)-halfdown)+stubslide,
779
cmemax, Ea(Y,y)+halfup+stubslide, 0, 2 );
932
clickmap_entry( 'r', cmtxt, clickmap, cmemin, (Ea(Y,y)-halfdown)+stubslide,
933
cmemax, Ea(Y,y)+halfup+stubslide, 0, 2, "" );
781
935
cmylast = Ea( Y, y );