Doxygen Source Code Documentation
1dgrayplot.c File Reference
#include "mrilib.h"#include "coxplot.h"#include "display.h"Go to the source code of this file.
Defines | |
| #define | TSGRAY_SEPARATE_YSCALE (1<<0) |
| #define | TSGRAY_FLIP_XY (1<<1) |
| #define | DEFAULT_NCOLOVR 20 |
Functions | |
| MEM_plotdata * | PLOT_tsgray (int npt, int nts, int ymask, float **y) |
| void | startup_timeout_CB (XtPointer client_data, XtIntervalId *id) |
| int | main (int argc, char *argv[]) |
| void | killfunc (void *fred) |
Variables | |
| char * | INIT_colovr [DEFAULT_NCOLOVR] |
| char * | INIT_labovr [DEFAULT_NCOLOVR] |
| MCW_DC * | dc |
| int | npt |
| int | nts |
| int | ymask = 0 |
| float ** | yar |
Define Documentation
|
|
Definition at line 82 of file 1dgrayplot.c. Referenced by main(). |
|
|
Definition at line 6 of file 1dgrayplot.c. Referenced by main(), and PLOT_tsgray(). |
|
|
Definition at line 5 of file 1dgrayplot.c. Referenced by main(), and PLOT_tsgray(). |
Function Documentation
|
|
13 May 2005: modified to read up to NVMAX numbers from stdin, rather than the fixed size array of length 9 of old * Definition at line 248 of file 1dgrayplot.c. Referenced by startup_timeout_CB().
00248 { exit(0) ; }
|
|
||||||||||||
|
convert three sub-briks to a raw dataset with consecutive triplets Definition at line 106 of file 1dgrayplot.c. References argc, DEFAULT_NCOLOVR, far, INIT_colovr, INIT_labovr, machdep(), malloc, MCW_new_DC(), memplot_to_postscript(), mp, MRI_FLOAT_PTR, mri_read_1D(), my_getenv(), npt, nts, MRI_IMAGE::nx, MRI_IMAGE::ny, PLOT_tsgray(), startup_timeout_CB(), strtod(), THD_MAX_NAME, TS_HELP_STRING, TSGRAY_FLIP_XY, TSGRAY_SEPARATE_YSCALE, yar, and ymask.
00107 {
00108 int iarg ;
00109 int install=0 , ignore=0 , use=0 , jj ;
00110 char * tsfile , * cpt ;
00111 char dname[THD_MAX_NAME] , subv[THD_MAX_NAME] ;
00112 MRI_IMAGE * flim ;
00113 float *far ;
00114 XtAppContext app ;
00115 Widget shell ;
00116 int out_ps=0 ; /* 28 Feb 2003 */
00117
00118 /*-- help? --*/
00119
00120 if( argc < 2 || strcmp(argv[1],"-help") == 0 ){
00121 printf("Usage: 1dgrayplot [options] tsfile\n"
00122 "Graphs the columns of a *.1D type time series file to the screen,\n"
00123 "sort of like 1dplot, but in grayscale.\n"
00124 "\n"
00125 "Options:\n"
00126 " -install = Install a new X11 colormap (for X11 PseudoColor)\n"
00127 " -ignore nn = Skip first 'nn' rows in the input file\n"
00128 " [default = 0]\n"
00129 " -flip = Plot x and y axes interchanged.\n"
00130 " [default: data columns plotted DOWN the screen]\n"
00131 " -sep = Separate scales for each column.\n"
00132 " -use mm = Plot 'mm' points\n"
00133 " [default: all of them]\n"
00134 " -ps = Don't draw plot in a window; instead, write it\n"
00135 " to stdout in PostScript format.\n"
00136 " N.B.: If you view this result in 'gv', you should\n"
00137 " turn 'anti-alias' off, and switch to\n"
00138 " landscape mode.\n"
00139
00140 "\n"
00141 TS_HELP_STRING
00142 ) ;
00143 exit(0) ;
00144 }
00145
00146 machdep() ;
00147
00148 /* 28 Feb 2003: scan for -ps flage NOW */
00149
00150 for( jj=1 ; jj < argc ; jj++ )
00151 if( strcmp(argv[jj],"-ps") == 0 ){ out_ps = 1; break; }
00152
00153 /* open X11 (if not doing PostScript) */
00154
00155 if( !out_ps ){
00156 shell = XtVaAppInitialize(
00157 &app , "AFNI" , NULL , 0 , &argc , argv , NULL , NULL ) ;
00158 if( shell == NULL ){
00159 fprintf(stderr,"** Cannot initialize X11!\n") ; exit(1) ;
00160 }
00161 }
00162
00163 cpt = my_getenv("TMPDIR") ; /* just for fun */
00164
00165 /*-- scan arguments that X11 didn't eat --*/
00166
00167 iarg = 1 ;
00168 while( iarg < argc && argv[iarg][0] == '-' ){
00169
00170 if( strcmp(argv[iarg],"-ps") == 0 ){ /* 28 Feb 2003: already handled above */
00171 iarg++ ; continue ;
00172 }
00173
00174 if( strcmp(argv[iarg],"-flip") == 0 ){
00175 ymask |= TSGRAY_FLIP_XY ; iarg++ ; continue ;
00176 }
00177
00178 if( strcmp(argv[iarg],"-sep") == 0 ){
00179 ymask |= TSGRAY_SEPARATE_YSCALE ; iarg++ ; continue ;
00180 }
00181
00182 if( strcmp(argv[iarg],"-install") == 0 ){
00183 install++ ; iarg++ ; continue ;
00184 }
00185
00186 if( strcmp(argv[iarg],"-ignore") == 0 ){
00187 ignore = strtod( argv[++iarg] , NULL ) ;
00188 if( ignore < 0 ){fprintf(stderr,"** Illegal -ignore value!\n");exit(1);}
00189 iarg++ ; continue ;
00190 }
00191
00192 if( strcmp(argv[iarg],"-use") == 0 ){
00193 use = strtod( argv[++iarg] , NULL ) ;
00194 if( use < 2 ){fprintf(stderr,"** Illegal -use value!\n");exit(1);}
00195 iarg++ ; continue ;
00196 }
00197
00198 fprintf(stderr,"** Unknown option: %s\n",argv[iarg]) ; exit(1) ;
00199 }
00200
00201 if( iarg >= argc ){
00202 fprintf(stderr,"** No tsfile on command line!\n") ; exit(1) ;
00203 }
00204
00205 if( !out_ps )
00206 dc = MCW_new_DC( shell , 16 ,
00207 DEFAULT_NCOLOVR , INIT_colovr , INIT_labovr ,
00208 1.0 , install ) ;
00209
00210 tsfile = argv[iarg] ;
00211 flim = mri_read_1D( tsfile ) ;
00212 if( flim == NULL ){
00213 fprintf(stderr,"** Can't read input file %s\n",tsfile) ;
00214 exit(1);
00215 }
00216 if( ignore >= flim->nx-1 ) ignore = 0 ;
00217
00218 if( use == 0 || use > flim->nx-ignore ) use = flim->nx-ignore ;
00219
00220 far = MRI_FLOAT_PTR(flim) ;
00221 yar = (float **) malloc( sizeof(float *) * flim->ny ) ;
00222 for( jj=0 ; jj < flim->ny ; jj++ )
00223 yar[jj] = far + (jj*flim->nx + ignore) ;
00224
00225 npt = use ;
00226 nts = flim->ny ;
00227
00228 /* start X11 */
00229
00230 if( !out_ps ){
00231 (void) XtAppAddTimeOut( app , 123 , startup_timeout_CB , NULL ) ;
00232 XtAppMainLoop(app) ; /* never returns */
00233 }
00234
00235 /* if get here, plot PostScript to stdout */
00236
00237 { MEM_plotdata *mp ;
00238 mp = PLOT_tsgray( npt , nts , ymask , yar ) ;
00239 memplot_to_postscript( "-" , mp ) ;
00240 }
00241 exit(0) ;
00242 }
|
|
||||||||||||||||||||
|
Definition at line 19 of file 1dgrayplot.c. References create_memplot_surely(), get_active_memplot(), mp, npt, nts, plotrect_memplot(), set_color_memplot(), set_thick_memplot(), TSGRAY_FLIP_XY, TSGRAY_SEPARATE_YSCALE, and ymask.
00020 {
00021 MEM_plotdata * mp ;
00022 float ybot,ytop , yfac , dx,dy , val ;
00023 int ii,jj , flipxy ;
00024 char str[32] ;
00025 int sepscl ;
00026
00027 if( npt < 2 || nts < 1 || y == NULL ) return NULL ;
00028
00029 /* find range of data */
00030
00031 ybot = ytop = y[0][0] ;
00032 for( jj=0 ; jj < nts ; jj++ ){
00033 for( ii=0 ; ii < npt ; ii++ ){
00034 val = y[jj][ii] ;
00035 if( ybot > val ) ybot = val ;
00036 else if( ytop < val ) ytop = val ;
00037 }
00038 }
00039 if( ybot >= ytop ) return NULL ;
00040 yfac = 1.0/(ytop-ybot) ;
00041
00042 dx = 1.0/npt ;
00043 dy = 1.0/nts ;
00044
00045 create_memplot_surely( "Gplot" , 1.0 ) ;
00046 set_color_memplot( 0.0 , 0.0 , 0.0 ) ;
00047 set_thick_memplot( 0.0 ) ;
00048
00049 flipxy = (ymask & TSGRAY_FLIP_XY) != 0 ;
00050 sepscl = (ymask & TSGRAY_SEPARATE_YSCALE) != 0 ;
00051
00052 for( jj=0 ; jj < nts ; jj++ ){
00053
00054 if( sepscl ){
00055 ybot = ytop = y[jj][0] ; /* find range of data */
00056 for( ii=1 ; ii < npt ; ii++ ){
00057 val = y[jj][ii] ;
00058 if( ybot > val ) ybot = val ;
00059 else if( ytop < val ) ytop = val ;
00060 }
00061 if( ybot >= ytop ) yfac = 1.0 ;
00062 else yfac = 1.0/(ytop-ybot) ;
00063 }
00064
00065 for( ii=0 ; ii < npt ; ii++ ){
00066 val = yfac*(ytop-y[jj][ii]) ;
00067 set_color_memplot( val,val,val ) ;
00068 if( flipxy )
00069 plotrect_memplot( ii*dx,jj*dy , (ii+1)*dx,(jj+1)*dy ) ;
00070 else
00071 plotrect_memplot( jj*dy,1.0-ii*dx , (jj+1)*dy,1.0-(ii+1)*dy ) ;
00072 }
00073 }
00074
00075 set_color_memplot( 0.0 , 0.0 , 0.0 ) ;
00076 mp = get_active_memplot() ;
00077 return mp ;
00078 }
|
|
||||||||||||
|
Definition at line 251 of file 1dgrayplot.c. References client_data, MCW_DC::display, killfunc(), memplot_to_topshell(), mp, npt, nts, PLOT_tsgray(), yar, and ymask. Referenced by main().
00252 {
00253 MEM_plotdata * mp ;
00254
00255 mp = PLOT_tsgray( npt , nts , ymask , yar ) ;
00256
00257 if( mp != NULL )
00258 (void) memplot_to_topshell( dc->display , mp , killfunc ) ;
00259
00260 return ;
00261 }
|
Variable Documentation
|
|
Definition at line 100 of file 1dgrayplot.c. |
|
|
Initial value: {
"#ffff00" , "#ffcc00" , "#ff9900" , "#ff6900" , "#ff4400" , "#ff0000" ,
"#0000ff" , "#0044ff" , "#0069ff" , "#0099ff" , "#00ccff" , "#00ffff" ,
"green" , "limegreen" , "violet" , "hotpink" ,
"white" , "#dddddd" , "#bbbbbb" , "black"
}Definition at line 84 of file 1dgrayplot.c. Referenced by main(). |
|
|
Initial value: {
"yellow" , "yell-oran" , "oran-yell" , "orange" , "oran-red" , "red" ,
"dk-blue", "blue" , "lt-blue1" , "lt-blue2" , "blue-cyan", "cyan" ,
"green" , "limegreen" , "violet" , "hotpink" ,
"white" , "gry-dd" , "gry-bb" , "black"
}Definition at line 91 of file 1dgrayplot.c. Referenced by main(). |
|
|
Definition at line 101 of file 1dgrayplot.c. Referenced by main(), PLOT_tsgray(), and startup_timeout_CB(). |
|
|
Definition at line 101 of file 1dgrayplot.c. Referenced by main(), PLOT_tsgray(), and startup_timeout_CB(). |
|
|
Definition at line 102 of file 1dgrayplot.c. Referenced by main(), and startup_timeout_CB(). |
|
|
Definition at line 101 of file 1dgrayplot.c. Referenced by main(), PLOT_tsgray(), and startup_timeout_CB(). |