00001 #include "coxplot.h"
00002 #include <math.h>
00003
00004
00005
00006
00007
00008
00009 #ifndef WAY_BIG
00010 # define WAY_BIG 1.e+10
00011 #endif
00012
00013 static float p10( float x ) ;
00014
00015 #undef NCLR_MAX
00016 #define NCLR_MAX 19
00017 static float ccc[NCLR_MAX][3] = {
00018 { 0.0 , 0.0 , 0.0 } ,
00019 { 0.9 , 0.0 , 0.0 } ,
00020 { 0.0 , 0.7 , 0.0 } ,
00021 { 0.0 , 0.0 , 0.9 } ,
00022 } ;
00023
00024 static int NCLR = 4 ;
00025
00026 static int ilab[4] = { 0,2,3,1 } ;
00027
00028 #define STGOOD(s) ( (s) != NULL && (s)[0] != '\0' )
00029
00030 #define SY 0.07
00031
00032 static float THIK = 0.003 ;
00033
00034
00035 static int xpush=1 , ypush=1 ;
00036
00037 void plot_ts_xypush( int a , int b ){ xpush=a; ypush=b; }
00038
00039 static float xxbot,xxtop , yybot,yytop ;
00040 static int nnaxx=-1,mmaxx=-1 , nnayy=-1,mmayy=-1 ;
00041
00042 void plot_ts_xfix( int nax, int max, float xb, float xt )
00043 {
00044 nnaxx = nax ; mmaxx = max ; xxbot = xb ; xxtop = xt ;
00045 }
00046
00047 void plot_ts_yfix( int nay, int may, float yb, float yt )
00048 {
00049 nnayy = nay ; mmayy = may ; yybot = yb ; yytop = yt ;
00050 }
00051
00052
00053
00054
00055
00056 static void init_colors(void)
00057 {
00058 static int first=1 ;
00059 char ename[32] , *eee ;
00060 float rf,gf,bf ;
00061 int ii ;
00062
00063 if( !first ) return ;
00064 first = 0 ;
00065
00066
00067 for( ii=0 ; ii < NCLR_MAX ; ii++ ){
00068 sprintf(ename,"AFNI_1DPLOT_COLOR_%02d",ii+1) ;
00069 eee = getenv(ename) ;
00070 if( eee == NULL && ii < 9 ){
00071 sprintf(ename,"AFNI_1DPLOT_COLOR_%1d",ii+1) ; eee = getenv(ename) ;
00072 }
00073 if( eee == NULL && ii <= 9 ){
00074 sprintf(ename,"AFNI_1DPLOT_COLOR_O%1d",ii+1) ; eee = getenv(ename) ;
00075 }
00076 if( eee != NULL ){
00077 rf=gf=bf = -1.0 ;
00078 sscanf( eee , "rgbi:%f/%f/%f" , &rf,&gf,&bf ) ;
00079 if( rf >= 0.0 && rf <= 1.0 && gf >= 0.0 && gf <= 1.0 && bf >= 0.0 && bf <= 1.0 ){
00080 ccc[ii][0] = rf ; ccc[ii][1] = gf ; ccc[ii][2] = bf ;
00081 NCLR = ii+1 ;
00082 } else {
00083 fprintf(stderr,
00084 "%s = %s is not in form 'rgbi:val/val/val' with each val in [0,1].\n" ,
00085 ename , eee ) ;
00086 }
00087 }
00088 }
00089
00090 eee = getenv("AFNI_1DPLOT_THIK") ;
00091 if( eee != NULL ){
00092 rf = strtod(eee,NULL) ;
00093 if( rf >= 0.0 && rf <= 0.05 ) THIK = rf ;
00094 else
00095 fprintf(stderr,"AFNI_1DPLOT_THIK is not in range [0,0.05].\n") ;
00096 }
00097 }
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112 MEM_plotdata * plot_ts_mem( int nx , float * x , int ny , int ymask , float ** y ,
00113 char * lab_xxx , char * lab_yyy , char * lab_top ,
00114 char ** nam_yyy )
00115 {
00116 int ii , jj , np , nnax,nnay , mmax,mmay ;
00117 float *xx , *yy ;
00118 float xbot,xtop , ybot,ytop , pbot,ptop , xobot,xotop,yobot,yotop ;
00119 char str[32] ;
00120 int yall , ysep ;
00121 float *ylo , *yhi , yll,yhh ;
00122 MEM_plotdata *mp ;
00123
00124
00125
00126 if( nx <= 1 || ny == 0 || y == NULL ) return NULL ;
00127
00128 init_colors() ;
00129
00130
00131
00132 if( x == NULL ){
00133 xx = (float *) malloc( sizeof(float) * nx ) ;
00134 for( ii=0 ; ii < nx ; ii++ ) xx[ii] = ii ;
00135 xbot = 0 ; xtop = nx-1 ;
00136 } else {
00137 xx = x ;
00138 xbot = WAY_BIG ; xtop = -WAY_BIG ;
00139 for( ii=0 ; ii < nx ; ii++ ){
00140 if( xx[ii] < xbot && xx[ii] < WAY_BIG ) xbot = xx[ii] ;
00141 if( xx[ii] > xtop && xx[ii] < WAY_BIG ) xtop = xx[ii] ;
00142 }
00143 if( xbot >= xtop ) return NULL ;
00144 }
00145
00146
00147
00148 pbot = p10(xbot) ; ptop = p10(xtop) ; if( ptop < pbot ) ptop = pbot ;
00149 if( nnaxx >= 0 ){
00150 nnax = nnaxx ; nnaxx = -1 ;
00151 mmax = mmaxx ;
00152 xbot = xxbot ;
00153 xtop = xxtop ;
00154 } else if( ptop != 0.0 && xpush ){
00155 np = (xtop-xbot) / ptop ;
00156 switch( np ){
00157 case 1: ptop *= 0.1 ; break ;
00158 case 2: ptop *= 0.2 ; break ;
00159 case 3: ptop *= 0.25 ; break ;
00160 case 4:
00161 case 5: ptop *= 0.5 ; break ;
00162 }
00163 xbot = floor( xbot/ptop ) * ptop ;
00164 xtop = ceil( xtop/ptop ) * ptop ;
00165 nnax = floor( (xtop-xbot) / ptop + 0.5 ) ;
00166 mmax = (nnax < 3) ? 10
00167 : (nnax < 6) ? 5 : 2 ;
00168 } else {
00169 nnax = 1 ; mmax = 10 ;
00170 ii = (int)rint(xtop-xbot) ;
00171 if( fabs(xtop-xbot-ii) < 0.01 && ii <= 200 ) mmax = ii ;
00172 }
00173
00174
00175
00176 yall = (ny == 1) || ((ymask & TSP_SEPARATE_YBOX) == 0) ;
00177 ysep = (ymask & TSP_SEPARATE_YSCALE) != 0 ;
00178
00179 ylo = (float *) malloc(sizeof(float)*ny) ;
00180 yhi = (float *) malloc(sizeof(float)*ny) ;
00181
00182 ybot = WAY_BIG ; ytop = -WAY_BIG ;
00183 for( jj=0 ; jj < ny ; jj++ ){
00184 yy = y[jj] ; yll = WAY_BIG ; yhh = -WAY_BIG ;
00185 for( ii=0 ; ii < nx ; ii++ ){
00186 if( yy[ii] < yll && yy[ii] < WAY_BIG ) yll = yy[ii] ;
00187 if( yy[ii] > yhh && yy[ii] < WAY_BIG ) yhh = yy[ii] ;
00188 }
00189 ylo[jj] = yll ; yhi[jj] = yhh ;
00190 if( ybot > yll ) ybot = yll ;
00191 if( ytop < yhh ) ytop = yhh ;
00192 if( yll >= yhh ){
00193 yhh = yll + 0.05*fabs(yll) + 0.5 ;
00194 yll = yll - 0.05*fabs(yll) - 0.5 ;
00195 ylo[jj] = yll ; yhi[jj] = yhh ;
00196 }
00197 }
00198 if( ybot >= ytop ){
00199 ytop = ybot + 0.05*fabs(ybot) + 0.5 ;
00200 ybot = ybot - 0.05*fabs(ybot) - 0.5 ;
00201 }
00202
00203
00204
00205 if( !ysep ){
00206 for( jj=0 ; jj < ny ; jj++ ){ ylo[jj] = ybot ; yhi[jj] = ytop ; }
00207 }
00208
00209
00210
00211 pbot = p10(ybot) ; ptop = p10(ytop) ; if( ptop < pbot ) ptop = pbot ;
00212 if( nnayy >= 0 ){
00213 nnay = nnayy ; nnayy = -1 ;
00214 mmay = mmayy ;
00215 ybot = yybot ;
00216 ytop = yytop ;
00217 for( jj=0 ; jj < ny ; jj++ ){ ylo[jj] = ybot ; yhi[jj] = ytop ; }
00218 } else if( ptop != 0.0 && ypush ){
00219 np = (ytop-ybot) / ptop ;
00220 switch( np ){
00221 case 1: ptop *= 0.1 ; break ;
00222 case 2: ptop *= 0.2 ; break ;
00223 case 3: ptop *= 0.25 ; break ;
00224 case 4:
00225 case 5: ptop *= 0.5 ; break ;
00226 }
00227 ybot = floor( ybot/ptop ) * ptop ;
00228 ytop = ceil( ytop/ptop ) * ptop ;
00229 nnay = floor( (ytop-ybot) / ptop + 0.5 ) ;
00230 mmay = (nnay < 3) ? 10
00231 : (nnay < 6) ? 5 : 2 ;
00232 } else {
00233 nnay = 1 ; mmay = 10 ;
00234 }
00235
00236 for( jj=0 ; jj < ny ; jj++ ){
00237 pbot = p10(ylo[jj]) ; ptop = p10(yhi[jj]) ; if( ptop < pbot ) ptop = pbot ;
00238 if( ptop != 0.0 ){
00239 np = (yhi[jj]-ylo[jj]) / ptop ;
00240 switch( np ){
00241 case 1: ptop *= 0.1 ; break ;
00242 case 2: ptop *= 0.2 ; break ;
00243 case 3: ptop *= 0.25 ; break ;
00244 case 4:
00245 case 5: ptop *= 0.5 ; break ;
00246 }
00247 ylo[jj] = floor( ylo[jj]/ptop ) * ptop ;
00248 yhi[jj] = ceil( yhi[jj]/ptop ) * ptop ;
00249 }
00250 }
00251
00252
00253
00254 create_memplot_surely( "tsplot" , 1.3 ) ;
00255 set_thick_memplot( 0.2*THIK ) ;
00256
00257
00258
00259 xobot = 0.15 ; xotop = 1.27 ;
00260 yobot = 0.1 ; yotop = 0.95 ;
00261
00262 if( STGOOD(lab_top) ){ yotop -= 0.02 ; yobot -= 0.01 ; }
00263 if( nam_yyy != NULL ){ xotop -= 0.16 ; xobot -= 0.02 ; }
00264
00265
00266
00267 set_color_memplot( 0.0 , 0.0 , 0.0 ) ;
00268 if( STGOOD(lab_xxx) )
00269 plotpak_pwritf( 0.5*(xobot+xotop) , yobot-0.06 , lab_xxx , 16 , 0 , 0 ) ;
00270
00271
00272
00273 set_color_memplot( 0.0 , 0.0 , 0.0 ) ;
00274 if( STGOOD(lab_yyy) )
00275 plotpak_pwritf( xobot-0.10 , 0.5*(yobot+yotop) , lab_yyy , 16 , 90 , 0 ) ;
00276
00277
00278
00279 set_color_memplot( 0.0 , 0.0 , 0.0 ) ;
00280 if( STGOOD(lab_top) )
00281 plotpak_pwritf( xobot+0.01 , yotop+0.01 , lab_top , 18 , 0 , -2 ) ;
00282
00283
00284
00285 if( yall ){
00286
00287
00288
00289 if( nam_yyy != NULL ){
00290 float yv = yotop ; int sz ;
00291
00292 for( jj=0 ; jj < ny ; jj++ ){
00293 if( STGOOD(nam_yyy[jj]) ){
00294 set_color_memplot( ccc[jj%NCLR][0] , ccc[jj%NCLR][1] , ccc[jj%NCLR][2] ) ;
00295 set_thick_memplot( THIK ) ;
00296 plotpak_line( xotop+0.008 , yv , xotop+0.042 , yv ) ;
00297 set_thick_memplot( 0.2*THIK ) ;
00298 set_color_memplot( 0.0 , 0.0 , 0.0 ) ;
00299 sz = (strlen(nam_yyy[jj]) <= 10) ? 12 : 10 ;
00300 plotpak_pwritf( xotop+0.048 , yv , nam_yyy[jj] , sz , 0 , -1 ) ;
00301 yv -= 0.05 ;
00302 }
00303 }
00304 }
00305
00306
00307
00308 set_color_memplot( 0.0 , 0.0 , 0.0 ) ;
00309 set_thick_memplot( 0.0 ) ;
00310 plotpak_set( xobot,xotop , yobot,yotop , xbot,xtop , ybot,ytop , 1 ) ;
00311 plotpak_perimm( nnax,mmax , nnay,mmay , ilab[(nnax>0)+2*(nnay>0)] ) ;
00312
00313
00314
00315 for( jj=0 ; jj < ny ; jj++ ){
00316 set_thick_memplot( THIK ) ;
00317 set_color_memplot( ccc[jj%NCLR][0] , ccc[jj%NCLR][1] , ccc[jj%NCLR][2] ) ;
00318
00319 yy = y[jj] ;
00320 for( ii=1 ; ii < nx ; ii++ ){
00321 if( xx[ii-1] < WAY_BIG && xx[ii] < WAY_BIG &&
00322 yy[ii-1] < WAY_BIG && yy[ii] < WAY_BIG )
00323
00324 plotpak_line( xx[ii-1] , yy[ii-1] , xx[ii] , yy[ii] ) ;
00325 }
00326 }
00327 set_thick_memplot( 0.0 ) ;
00328 set_color_memplot( 0.0 , 0.0 , 0.0 ) ;
00329
00330 } else {
00331
00332 float dyo = (yotop-yobot) / ( (1.0+SY) * ny - SY ) ;
00333
00334
00335
00336 if( nam_yyy != NULL ){
00337 float yv = yotop ; int sz ;
00338
00339 for( jj=0 ; jj < ny ; jj++ ){
00340 yll = yobot + jj*(1.0+SY)*dyo ; yhh = yll + dyo ;
00341 if( STGOOD(nam_yyy[jj]) ){
00342 set_color_memplot( ccc[jj%NCLR][0] , ccc[jj%NCLR][1] , ccc[jj%NCLR][2] ) ;
00343 set_thick_memplot( 2*THIK ) ;
00344 yv = 0.7*yhh + 0.3*yll ;
00345 plotpak_line( xotop+0.008 , yv , xotop+0.042 , yv ) ;
00346 set_thick_memplot( 0.5*THIK ) ;
00347 set_color_memplot( 0.0 , 0.0 , 0.0 ) ;
00348 sz = (strlen(nam_yyy[jj]) <= 10) ? 12 : 10 ;
00349 plotpak_pwritf( xotop+0.048 , yv , nam_yyy[jj] , sz , 0 , -1 ) ;
00350 }
00351 }
00352 }
00353
00354
00355
00356 for( jj=ny-1 ; jj >= 0 ; jj-- ){
00357 yll = yobot + jj*(1.0+SY)*dyo ; yhh = yll + dyo ;
00358 plotpak_set( xobot,xotop , yll,yhh , xbot,xtop , ylo[jj],yhi[jj] , 1 ) ;
00359
00360 if( nnay > 0 ){
00361 nnay = 1 ;
00362 pbot = p10(ylo[jj]) ; ptop = p10(yhi[jj]) ;
00363 if( ptop > pbot && pbot > 0.0 ) ptop = pbot ;
00364 if( ptop != 0.0 ) mmay = floor( (yhi[jj]-ylo[jj]) / ptop + 0.5 ) ;
00365 else mmay = 5 ;
00366
00367 if( mmay == 1 ) mmay = 5 ;
00368 else if( mmay == 2 ) mmay = 4 ;
00369 else if( mmay == 3 ) mmay = 6 ;
00370 }
00371
00372 set_color_memplot( 0.0 , 0.0 , 0.0 ) ;
00373 plotpak_perimm( nnax,mmax , nnay,mmay , ilab[(nnax>0)*(jj==0)+2*(nnay>0)] ) ;
00374 if( ylo[jj] < 0.0 && yhi[jj] > 0.0 ){
00375 plotpak_setlin(5) ;
00376 plotpak_line( xbot,0.0 , xtop,0.0 ) ;
00377 plotpak_setlin(1) ;
00378 }
00379
00380 set_color_memplot( ccc[jj%NCLR][0] , ccc[jj%NCLR][1] , ccc[jj%NCLR][2] ) ;
00381 set_thick_memplot( THIK ) ;
00382
00383 yy = y[jj] ;
00384 for( ii=1 ; ii < nx ; ii++ ){
00385 if( xx[ii-1] < WAY_BIG && xx[ii] < WAY_BIG &&
00386 yy[ii-1] < WAY_BIG && yy[ii] < WAY_BIG )
00387
00388 plotpak_line( xx[ii-1] , yy[ii-1] , xx[ii] , yy[ii] ) ;
00389 }
00390 set_thick_memplot( 0.0 ) ;
00391 set_color_memplot( 0.0 , 0.0 , 0.0 ) ;
00392 }
00393 }
00394
00395
00396
00397 if( xx != x ) free(xx) ;
00398 free(ylo) ; free(yhi) ;
00399
00400 mp = get_active_memplot() ;
00401 return mp ;
00402 }
00403
00404
00405
00406
00407
00408
00409
00410
00411 void plot_ts_lab( Display * dpy ,
00412 int nx , float * x , int ny , float ** y ,
00413 char * lab_xxx , char * lab_yyy , char * lab_top ,
00414 char ** nam_yyy , void_func * killfunc )
00415 {
00416 MEM_plotdata * mp ;
00417 int ymask = 0 ;
00418
00419 if( dpy == NULL ) return ;
00420
00421 if( ny < 0 ){ ymask = TSP_SEPARATE_YBOX ; ny = -ny ; }
00422
00423 mp = plot_ts_mem( nx,x , ny,ymask,y , lab_xxx , lab_yyy , lab_top , nam_yyy ) ;
00424 if( mp != NULL )
00425 (void) memplot_to_topshell( dpy , mp , killfunc ) ;
00426
00427 return ;
00428 }
00429
00430
00431
00432
00433
00434
00435
00436 static float p10( float x )
00437 {
00438 double y ;
00439
00440 if( x == 0.0 ) return 0.0 ;
00441 if( x < 0.0 ) x = -x ;
00442 y = floor(log10(x)+0.000001) ; y = pow( 10.0 , y ) ;
00443 return (float) y ;
00444 }
00445
00446
00447
00448 MEM_topshell_data * plot_ts_init( Display * dpy ,
00449 float xbot , float xtop ,
00450 int ny , float ybot , float ytop ,
00451 char * lab_xxx , char * lab_yyy ,
00452 char * lab_top , char ** nam_yyy ,
00453 void_func * killfunc )
00454 {
00455 int ii , jj , np , nnax,nnay , mmax,mmay , yall ;
00456 float pbot,ptop , xobot,xotop,yobot,yotop , yll,yhh ;
00457 char str[32] ;
00458 float * ud ;
00459 MEM_topshell_data * mp ;
00460
00461
00462
00463 if( dpy == NULL || ny == 0 || xbot >= xtop || ybot >= ytop ) return NULL ;
00464
00465 init_colors() ;
00466
00467
00468
00469 pbot = p10(xbot) ; ptop = p10(xtop) ; if( ptop < pbot ) ptop = pbot ;
00470 if( ptop != 0.0 && xpush ){
00471 np = (xtop-xbot) / ptop ;
00472 switch( np ){
00473 case 1: ptop *= 0.1 ; break ;
00474 case 2: ptop *= 0.2 ; break ;
00475 case 3: ptop *= 0.25 ; break ;
00476 case 4:
00477 case 5: ptop *= 0.5 ; break ;
00478 }
00479 xbot = floor( xbot/ptop ) * ptop ;
00480 xtop = ceil( xtop/ptop ) * ptop ;
00481 nnax = floor( (xtop-xbot) / ptop + 0.5 ) ;
00482 mmax = (nnax < 3) ? 10
00483 : (nnax < 6) ? 5 : 2 ;
00484 } else {
00485 nnax = 1 ; mmax = 10 ;
00486 ii = (int)rint(xtop-xbot) ;
00487 if( fabs(xtop-xbot-ii) < 0.01 && ii <= 200 ) mmax = ii ;
00488 }
00489
00490
00491
00492 yall = (ny > 0) ; if( !yall ) ny = -ny ;
00493
00494 pbot = p10(ybot) ; ptop = p10(ytop) ; if( ptop < pbot ) ptop = pbot ;
00495 if( ptop != 0.0 && ypush ){
00496 np = (ytop-ybot) / ptop ;
00497 switch( np ){
00498 case 1: ptop *= 0.1 ; break ;
00499 case 2: ptop *= 0.2 ; break ;
00500 case 3: ptop *= 0.25 ; break ;
00501 case 4:
00502 case 5: ptop *= 0.5 ; break ;
00503 }
00504 ybot = floor( ybot/ptop ) * ptop ;
00505 ytop = ceil( ytop/ptop ) * ptop ;
00506 nnay = floor( (ytop-ybot) / ptop + 0.5 ) ;
00507 mmay = (nnay < 3) ? 10
00508 : (nnay < 6) ? 5 : 2 ;
00509 } else {
00510 nnay = 1 ; mmay = 10 ;
00511 }
00512
00513
00514
00515 create_memplot_surely( "Tsplot" , 1.3 ) ;
00516 set_thick_memplot( 0.5*THIK ) ;
00517
00518
00519
00520 xobot = 0.15 ; xotop = 1.27 ;
00521 yobot = 0.1 ; yotop = 0.95 ;
00522
00523 if( STGOOD(lab_top) ){ yotop -= 0.02 ; yobot -= 0.01 ; }
00524 if( nam_yyy != NULL ){ xotop -= 0.16 ; xobot -= 0.02 ; }
00525
00526
00527
00528 set_color_memplot( 0.0 , 0.0 , 0.0 ) ;
00529 if( STGOOD(lab_xxx) )
00530 plotpak_pwritf( 0.5*(xobot+xotop) , yobot-0.06 , lab_xxx , 16 , 0 , 0 ) ;
00531
00532
00533
00534 set_color_memplot( 0.0 , 0.0 , 0.0 ) ;
00535 if( STGOOD(lab_yyy) )
00536 plotpak_pwritf( xobot-0.10 , 0.5*(yobot+yotop) , lab_yyy , 16 , 90 , 0 ) ;
00537
00538
00539
00540 set_color_memplot( 0.0 , 0.0 , 0.0 ) ;
00541 if( STGOOD(lab_top) )
00542 plotpak_pwritf( xobot+0.01 , yotop+0.01 , lab_top , 18 , 0 , -2 ) ;
00543
00544
00545
00546 ud = (float *) malloc( sizeof(float) * 8 ) ;
00547 ud[0] = xobot ; ud[1] = xotop ; ud[2] = yobot ; ud[3] = yotop ;
00548 ud[4] = xbot ; ud[5] = xtop ; ud[6] = ybot ; ud[7] = ytop ;
00549
00550 if( yall ){
00551
00552
00553
00554 if( nam_yyy != NULL ){
00555 float yv = yotop ; int sz ;
00556
00557 for( jj=0 ; jj < ny ; jj++ ){
00558 if( STGOOD(nam_yyy[jj]) ){
00559 set_color_memplot( ccc[jj%NCLR][0] , ccc[jj%NCLR][1] , ccc[jj%NCLR][2] ) ;
00560 set_thick_memplot( 2*THIK ) ;
00561 plotpak_line( xotop+0.008 , yv , xotop+0.042 , yv ) ;
00562 set_thick_memplot( 0.5*THIK ) ;
00563 set_color_memplot( 0.0 , 0.0 , 0.0 ) ;
00564 sz = (strlen(nam_yyy[jj]) <= 10) ? 12 : 10 ;
00565 plotpak_pwritf( xotop+0.048 , yv , nam_yyy[jj] , sz , 0 , -1 ) ;
00566 yv -= 0.05 ;
00567 }
00568 }
00569 }
00570
00571
00572
00573 set_color_memplot( 0.0 , 0.0 , 0.0 ) ;
00574 plotpak_set( xobot,xotop , yobot,yotop , xbot,xtop , ybot,ytop , 1 ) ;
00575 plotpak_perimm( nnax,mmax , nnay,mmay , ilab[(nnax>0)+2*(nnay>0)] ) ;
00576
00577 } else {
00578
00579 float dyo = (yotop-yobot) / ( (1.0+SY) * ny - SY ) ;
00580
00581
00582
00583 if( nam_yyy != NULL ){
00584 float yv = yotop ; int sz ;
00585
00586 for( jj=0 ; jj < ny ; jj++ ){
00587 yll = yobot + jj*(1.0+SY)*dyo ; yhh = yll + dyo ;
00588 if( STGOOD(nam_yyy[jj]) ){
00589 set_color_memplot( ccc[jj%NCLR][0] , ccc[jj%NCLR][1] , ccc[jj%NCLR][2] ) ;
00590 set_thick_memplot( 2*THIK ) ;
00591 yv = 0.7*yhh + 0.3*yll ;
00592 plotpak_line( xotop+0.008 , yv , xotop+0.042 , yv ) ;
00593 set_thick_memplot( 0.5*THIK ) ;
00594 set_color_memplot( 0.0 , 0.0 , 0.0 ) ;
00595 sz = (strlen(nam_yyy[jj]) <= 10) ? 12 : 10 ;
00596 plotpak_pwritf( xotop+0.048 , yv , nam_yyy[jj] , sz , 0 , -1 ) ;
00597 }
00598 }
00599 }
00600
00601
00602
00603 nnay = 1 ;
00604 pbot = p10(ybot) ; ptop = p10(ytop) ;
00605 if( ptop > pbot && pbot > 0.0 ) ptop = pbot ;
00606 if( ptop != 0.0 ) mmay = floor( (ytop-ybot) / ptop + 0.5 ) ;
00607 else mmay = 5 ;
00608
00609 if( mmay == 1 ) mmay = 5 ;
00610 else if( mmay == 2 ) mmay = 4 ;
00611 else if( mmay == 3 ) mmay = 6 ;
00612
00613 for( jj=ny-1 ; jj >= 0 ; jj-- ){
00614 yll = yobot + jj*(1.0+SY)*dyo ; yhh = yll + dyo ;
00615 plotpak_set( xobot,xotop , yll,yhh , xbot,xtop , ybot,ytop , 1 ) ;
00616 set_color_memplot( 0.0 , 0.0 , 0.0 ) ;
00617 plotpak_perimm( nnax,mmax , nnay,mmay , ilab[(nnax>0)*(jj==0)+2*(nnay>0)] ) ;
00618 if( ybot < 0.0 && ytop > 0.0 ){
00619 plotpak_setlin(5) ;
00620 plotpak_line( xbot,0.0 , xtop,0.0 ) ;
00621 plotpak_setlin(1) ;
00622 }
00623 }
00624 }
00625
00626
00627
00628 mp = memplot_to_topshell( dpy , get_active_memplot() , killfunc ) ;
00629 if( mp == NULL ){ free(ud) ; return NULL; }
00630 mp->userdata = ud ;
00631
00632
00633
00634 return mp ;
00635 }
00636
00637
00638
00639 void plot_ts_addto( MEM_topshell_data * mp ,
00640 int nx , float * x , int ny , float ** y )
00641 {
00642 int ii , jj , yall , start ;
00643 float pbot,ptop , xobot,xotop,yobot,yotop , yll,yhh ;
00644 float xbot,xtop , ybot,ytop ;
00645 float * yy , * xx ;
00646 float * ud ;
00647
00648 if( mp == NULL || mp->userdata == NULL || ! mp->valid ||
00649 nx <= 1 || ny == 0 || x == NULL || y == NULL ) return ;
00650
00651 init_colors() ;
00652
00653 ud = (float *) mp->userdata ;
00654 xobot = ud[0] ; xotop = ud[1] ; yobot = ud[2] ; yotop = ud[3] ;
00655 xbot = ud[4] ; xtop = ud[5] ; ybot = ud[6] ; ytop = ud[7] ;
00656
00657 yall = (ny > 0) ; if( !yall ) ny = -ny ;
00658
00659 ii = set_active_memplot( MEMPLOT_IDENT(mp->mp) ) ;
00660 if( ii != 0 ) return ;
00661
00662 start = MEMPLOT_NLINE(mp->mp) ;
00663 xx = x ;
00664
00665 if( yall ){
00666
00667 plotpak_set( xobot,xotop , yobot,yotop , xbot,xtop , ybot,ytop , 1 ) ;
00668 set_thick_memplot( THIK ) ;
00669
00670
00671
00672 for( jj=0 ; jj < ny ; jj++ ){
00673 set_color_memplot( ccc[jj%NCLR][0] , ccc[jj%NCLR][1] , ccc[jj%NCLR][2] ) ;
00674
00675 yy = y[jj] ;
00676 for( ii=1 ; ii < nx ; ii++ ){
00677 if( xx[ii-1] < WAY_BIG && xx[ii] < WAY_BIG &&
00678 yy[ii-1] < WAY_BIG && yy[ii] < WAY_BIG )
00679
00680 plotpak_line( xx[ii-1] , yy[ii-1] , xx[ii] , yy[ii] ) ;
00681 }
00682 }
00683 set_thick_memplot( 0.0 ) ;
00684 set_color_memplot( 0.0 , 0.0 , 0.0 ) ;
00685
00686 } else {
00687
00688 float dyo = (yotop-yobot) / ( (1.0+SY) * ny - SY ) ;
00689
00690 set_thick_memplot( THIK ) ;
00691
00692 for( jj=ny-1 ; jj >= 0 ; jj-- ){
00693 yll = yobot + jj*(1.0+SY)*dyo ; yhh = yll + dyo ;
00694 plotpak_set( xobot,xotop , yll,yhh , xbot,xtop , ybot,ytop , 1 ) ;
00695 set_color_memplot( ccc[jj%NCLR][0] , ccc[jj%NCLR][1] , ccc[jj%NCLR][2] ) ;
00696
00697 yy = y[jj] ;
00698 for( ii=1 ; ii < nx ; ii++ ){
00699 if( xx[ii-1] < WAY_BIG && xx[ii] < WAY_BIG &&
00700 yy[ii-1] < WAY_BIG && yy[ii] < WAY_BIG )
00701
00702 plotpak_line( xx[ii-1] , yy[ii-1] , xx[ii] , yy[ii] ) ;
00703 }
00704 }
00705 set_thick_memplot( 0.0 ) ;
00706 set_color_memplot( 0.0 , 0.0 , 0.0 ) ;
00707 }
00708
00709 memplot_to_X11_sef( XtDisplay(mp->drawing) , XtWindow(mp->drawing) ,
00710 mp->mp , start,0,MEMPLOT_FREE_ASPECT ) ;
00711
00712 return ;
00713 }