Doxygen Source Code Documentation
plug_ttget.c File Reference
#include "afni.h"#include <sys/types.h>#include <sys/socket.h>#include <netinet/in.h>#include <netdb.h>#include <stdio.h>#include <arpa/inet.h>Go to the source code of this file.
Defines | |
| #define | CORONAL_NUM 38 |
| #define | SAGITTAL_NUM 18 |
| #define | AXIAL_NUM 27 |
| #define | TTAHOME "http://128.231.212.175/TTA/" |
| #define | SKIPCOM {if(ch == '#') do{ch=ndata[++id];}while(id<nn-1 && ch != '\n');} |
| #define | NUMSCAN(var) |
| #define | NUM_ORIENT_STRINGS 4 |
Functions | |
| char * | TTget_URL (int code, float xx, float yy, float zz) |
| MRI_IMAGE * | TTget_ppm (char *url) |
| char * | xxx_name_to_inet (char *host) |
| char * | self_to_inet (void) |
| int | is_nih_host (void) |
| int | can_get_testfile (void) |
| char * | TTget_main (PLUGIN_interface *) |
| DEFINE_PLUGIN_PROTOTYPE PLUGIN_interface * | PLUGIN_init (int ncall) |
| void | TTget_recv (int why, int np, int *ijk, void *junk) |
Variables | |
| float | coronal_yy [] |
| char * | coronal_ff [] |
| float | sagittal_xx [] |
| char * | sagittal_ff [] |
| float | axial_zz [] |
| char * | axial_ff [] |
| char * | orient_strings [4] = { "None", "Axial", "Sagittal", "Coronal" } |
| int | orient = 0 |
| int | recv_key = -1 |
| Three_D_View * | old_im3d = NULL |
| char | old_url [256] = "\0" |
| void * | impop = NULL |
Define Documentation
|
|
Definition at line 47 of file plug_ttget.c. Referenced by TTget_URL(). |
|
|
Definition at line 9 of file plug_ttget.c. Referenced by TTget_URL(). |
|
|
Definition at line 259 of file plug_ttget.c. Referenced by PLUGIN_init(), and TTget_main(). |
|
|
Value: { SKIPCOM ; \
while( id<nn-1 && !isdigit(ch) ){ch = ndata[++id]; SKIPCOM; } \
for( nch=0 ; id<nn-1 && isdigit(ch) ; nch++,ch=ndata[++id] ) {buf[nch] = ch ;} \
buf[nch]='\0'; \
var = strtol( buf, NULL, 10 ) ; } |
|
|
Definition at line 32 of file plug_ttget.c. Referenced by TTget_URL(). |
|
|
|
|
|
Definition at line 63 of file plug_ttget.c. Referenced by can_get_testfile(), and TTget_URL(). |
Function Documentation
|
|
Definition at line 245 of file plug_ttget.c. References free, getenv(), NI_read_URL(), and TTAHOME. Referenced by PLUGIN_init().
00246 {
00247 char *ttahome, *ndata=NULL, url[256]; int nn ;
00248
00249 ttahome = getenv("AFNI_TTAHOME"); if( ttahome == NULL ) ttahome = TTAHOME;
00250 strcpy(url,ttahome) ; strcat(url,"testfile") ;
00251 nn = NI_read_URL( url, (char **)&ndata ) ;
00252 if( nn <= 0 || ndata == NULL ) return 0 ;
00253 if( ndata != NULL ) free(ndata) ;
00254 return 1 ;
00255 }
|
|
|
Definition at line 214 of file plug_ttget.c. References self_to_inet(). Referenced by PLUGIN_init().
00215 {
00216 char *ipad = self_to_inet() ;
00217
00218 if( ipad == NULL ) return 0 ;
00219
00220 if( strstr(ipad,"128.231.") == ipad ) return 1 ;
00221 if( strstr(ipad,"137.187.") == ipad ) return 1 ;
00222
00223 #if 1
00224 if( strstr(ipad,"130.14." ) == ipad ) return 1 ;
00225 if( strstr(ipad,"156.40." ) == ipad ) return 1 ;
00226 if( strstr(ipad,"165.112.") == ipad ) return 1 ;
00227 if( strstr(ipad,"157.98." ) == ipad ) return 1 ;
00228 #endif
00229
00230 #if 1
00231 if( strstr(ipad,"129.43." ) == ipad ) return 1 ;
00232 if( strstr(ipad,"199.249.158." ) == ipad ) return 1 ;
00233 if( strstr(ipad,"209.218.0." ) == ipad ) return 1 ;
00234 if( strstr(ipad,"130.14." ) == ipad ) return 1 ;
00235 if( strstr(ipad,"131.158.140." ) == ipad ) return 1 ;
00236 if( strstr(ipad,"150.148.11" ) == ipad ) return 1 ;
00237 if( strstr(ipad,"150.148.21" ) == ipad ) return 1 ;
00238 #endif
00239
00240 return 0 ;
00241 }
|
|
|
Definition at line 270 of file plug_ttget.c. References can_get_testfile(), is_nih_host(), NUM_ORIENT_STRINGS, orient, orient_strings, and TTget_main().
00271 {
00272 PLUGIN_interface * plint ;
00273
00274 #if 1
00275 return NULL ;
00276 #endif
00277
00278 if( ncall > 0 || !is_nih_host() || !can_get_testfile() ) return NULL ;
00279
00280 plint = PLUTO_new_interface( "TT Atlas",
00281 "TT Atlas display",
00282 NULL,
00283 PLUGIN_CALL_VIA_MENU, TTget_main ) ;
00284
00285 PLUTO_add_option( plint, "Mode", "MODE", TRUE ) ;
00286
00287 PLUTO_add_string( plint, "Orient", NUM_ORIENT_STRINGS, orient_strings, orient ) ;
00288
00289 return plint ;
00290 }
|
|
|
Definition at line 204 of file plug_ttget.c. References xxx_name_to_inet(). Referenced by is_nih_host().
00205 {
00206 char hname[1048]="localhost" ;
00207 static char *ipad=NULL ;
00208 if( ipad == NULL ){ gethostname(hname,1048); ipad = xxx_name_to_inet(hname); }
00209 return ipad ;
00210 }
|
|
|
Definition at line 302 of file plug_ttget.c. References AFNI_receive_control(), AFNI_receive_init(), EVERYTHING_SHUTDOWN, IM3D_OPEN, NUM_ORIENT_STRINGS, old_url, orient, orient_strings, PLUTO_string_index(), RECEIVE_VIEWPOINT_MASK, recv_key, and TTget_recv(). Referenced by PLUGIN_init().
00303 {
00304 char *str ;
00305
00306 PLUTO_next_option(plint) ;
00307 str = PLUTO_get_string(plint) ;
00308 orient = PLUTO_string_index( str, NUM_ORIENT_STRINGS, orient_strings ) ;
00309
00310 old_url[0] = '\0' ;
00311
00312 if( plint->im3d != old_im3d || !IM3D_OPEN(plint->im3d) ){
00313 if( recv_key >= 0 ){
00314 AFNI_receive_control( old_im3d,recv_key,EVERYTHING_SHUTDOWN,NULL ) ;
00315 recv_key = -1 ;
00316 }
00317 old_im3d = plint->im3d ;
00318 if( !IM3D_OPEN(plint->im3d) )
00319 return "***************************************\n"
00320 "TTget_main: AFNI controller isn't open!\n"
00321 "***************************************" ;
00322 }
00323
00324 if( orient == 0 && recv_key >= 0 ){
00325 AFNI_receive_control( plint->im3d,recv_key,EVERYTHING_SHUTDOWN,NULL ) ;
00326 recv_key = -1 ;
00327 } else if( orient > 0 && recv_key < 0 ){
00328 recv_key = AFNI_receive_init( plint->im3d, RECEIVE_VIEWPOINT_MASK,
00329 TTget_recv, NULL , "TTget_recv" ) ;
00330 }
00331
00332 return NULL ;
00333 }
|
|
|
Definition at line 123 of file plug_ttget.c. References free, maxval, mri_new(), MRI_RGB_PTR, NI_read_URL(), and NUMSCAN. Referenced by TTget_recv().
00124 {
00125 int ii,nn, ch,nch, nx,ny,maxval, id ;
00126 char buf[32] ;
00127 byte *ndata=NULL, *bar ;
00128 MRI_IMAGE *im ;
00129
00130 nn = NI_read_URL( url, (char **)&ndata ) ;
00131
00132 if( nn < 40960 || ndata == NULL || ndata[0] != 'P' || ndata[1] != '6' ){
00133 if( ndata != NULL ) free(ndata) ;
00134 return NULL ;
00135 }
00136
00137 id = 2 ; ch = ndata[id] ; /* start scan after "P6" */
00138
00139 #define SKIPCOM \
00140 {if(ch == '#') do{ch=ndata[++id];}while(id<nn-1 && ch != '\n');}
00141
00142 #define NUMSCAN(var) \
00143 { SKIPCOM ; \
00144 while( id<nn-1 && !isdigit(ch) ){ch = ndata[++id]; SKIPCOM; } \
00145 for( nch=0 ; id<nn-1 && isdigit(ch) ; nch++,ch=ndata[++id] ) {buf[nch] = ch ;} \
00146 buf[nch]='\0'; \
00147 var = strtol( buf, NULL, 10 ) ; }
00148
00149 NUMSCAN(nx) ; if( nx <= 2 || id >= nn-1 ){ free(ndata); return NULL; }
00150 NUMSCAN(ny) ; if( ny <= 2 || id >= nn-1 ){ free(ndata); return NULL; }
00151 NUMSCAN(maxval);
00152 if( maxval <= 7 || maxval > 255 || id >= nn-1 ){ free(ndata); return NULL; }
00153
00154 id++ ;
00155 if( nn-id < 3*nx*ny ){ free(ndata); return NULL; }
00156
00157 im = mri_new( nx, ny, MRI_rgb ) ;
00158 bar = MRI_RGB_PTR(im) ;
00159 memcpy( bar, ndata+id, 3*nx*ny ) ;
00160 free(ndata) ;
00161
00162 if( maxval < 255 ){
00163 float fac = 255.4/maxval ;
00164 for( ii=0 ; ii < 3*nx*ny ; ii++ ) bar[ii] = (byte)( bar[ii]*fac ) ;
00165 }
00166
00167 return im ;
00168 }
|
|
||||||||||||||||||||
|
Definition at line 339 of file plug_ttget.c. References IM3D_OPEN, impop, mri_free(), old_url, orient, PLUTO_popup_image(), RECEIVE_VIEWPOINT, TTget_ppm(), TTget_URL(), VIEW_TALAIRACH_TYPE, AFNI_view_info::view_type, Three_D_View::vinfo, AFNI_view_info::xi, AFNI_view_info::yj, and AFNI_view_info::zk. Referenced by TTget_main().
00340 {
00341 if( orient == 0 ||
00342 !IM3D_OPEN(old_im3d) ||
00343 old_im3d->vinfo->view_type != VIEW_TALAIRACH_TYPE ) return ;
00344
00345 switch( why ){
00346
00347 case RECEIVE_VIEWPOINT:{ /*-- change of crosshair location --*/
00348 MRI_IMAGE *im ;
00349 char *url ;
00350
00351 url = TTget_URL( orient-1, old_im3d->vinfo->xi,
00352 old_im3d->vinfo->yj, old_im3d->vinfo->zk ) ;
00353
00354 if( strcmp(url,old_url) == 0 ) return ;
00355 strcpy(old_url,url) ;
00356
00357 im = TTget_ppm( url ) ; if( im == NULL ) return ;
00358
00359 impop = PLUTO_popup_image( impop, im ) ;
00360 mri_free(im) ;
00361 }
00362 break ;
00363
00364 }
00365
00366 return ;
00367 }
|
|
||||||||||||||||||||
|
(xx,yy,zz) in RAI (Dicom) coords; code is (0=axial,1=sag,2=cor). Definition at line 69 of file plug_ttget.c. References axial_ff, AXIAL_NUM, axial_zz, coronal_ff, CORONAL_NUM, coronal_yy, getenv(), sagittal_ff, SAGITTAL_NUM, sagittal_xx, and TTAHOME. Referenced by TTget_recv().
00070 {
00071 static char nbuf[256] ;
00072 char *ttahome ;
00073 int ii,jj,kk ;
00074
00075 ttahome = getenv("AFNI_TTAHOME"); if( ttahome == NULL ) ttahome = TTAHOME;
00076
00077 switch( code ){
00078 case 1: /* sagittal */
00079 xx = fabs(xx) ;
00080 if( xx <= sagittal_xx[0] ){
00081 ii = 0 ;
00082 } else if( xx >= sagittal_xx[SAGITTAL_NUM-1] ){
00083 ii = SAGITTAL_NUM - 1 ;
00084 } else {
00085 for( ii=1 ; ii < SAGITTAL_NUM && xx > sagittal_xx[ii] ; ii++ ) ; /* nada */
00086 if( fabs(xx-sagittal_xx[ii-1]) < fabs(xx-sagittal_xx[ii]) ) ii-- ;
00087 }
00088 strcpy(nbuf,ttahome) ; strcat(nbuf,sagittal_ff[ii]) ;
00089 break ;
00090
00091 case 2: /* coronal */
00092 yy = -yy ;
00093 if( yy <= coronal_yy[0] ){
00094 jj = 0 ;
00095 } else if( yy >= coronal_yy[CORONAL_NUM-1] ){
00096 jj = CORONAL_NUM - 1 ;
00097 } else {
00098 for( jj=1 ; jj < CORONAL_NUM && yy > coronal_yy[jj] ; jj++ ) ; /* nada */
00099 if( fabs(yy-coronal_yy[jj-1]) < fabs(yy-coronal_yy[jj]) ) jj-- ;
00100 }
00101 strcpy(nbuf,ttahome) ; strcat(nbuf,coronal_ff[jj]) ;
00102 break ;
00103
00104 default:
00105 case 0: /* axial */
00106 if( zz <= axial_zz[0] ){
00107 kk = 0 ;
00108 } else if( zz >= axial_zz[AXIAL_NUM-1] ){
00109 kk = AXIAL_NUM - 1 ;
00110 } else {
00111 for( kk=1 ; kk < AXIAL_NUM && zz > axial_zz[kk] ; kk++ ) ; /* nada */
00112 if( fabs(zz-axial_zz[kk-1]) < fabs(zz-axial_zz[kk]) ) kk-- ;
00113 }
00114 strcpy(nbuf,ttahome) ; strcat(nbuf,axial_ff[kk]) ;
00115 break ;
00116 }
00117
00118 return nbuf ;
00119 }
|
|
|
Definition at line 186 of file plug_ttget.c. References malloc.
00187 {
00188 struct hostent * hostp ;
00189 char * iname = NULL, * str ;
00190 int ll ;
00191
00192 if( host == NULL || host[0] == '\0' ) return NULL ;
00193 hostp = gethostbyname(host) ; if( hostp == NULL ) return NULL ;
00194
00195 str = inet_ntoa(*((struct in_addr *)(hostp->h_addr))) ;
00196 if( str == NULL || str[0] == '\0' ) return NULL ;
00197
00198 ll = strlen(str) ; iname = malloc(ll+1) ; strcpy(iname,str) ;
00199 return iname ;
00200 }
|
Variable Documentation
|
|
Initial value: {
"tt_horm40.ppm.gz", "tt_horm36.ppm.gz", "tt_horm32.ppm.gz", "tt_horm28.ppm.gz",
"tt_horm24.ppm.gz", "tt_horm20.ppm.gz", "tt_horm16.ppm.gz", "tt_horm12.ppm.gz",
"tt_horm08.ppm.gz", "tt_horm04.ppm.gz", "tt_horm01.ppm.gz", "tt_horp01.ppm.gz",
"tt_horp04.ppm.gz", "tt_horp08.ppm.gz", "tt_horp12.ppm.gz", "tt_horp16.ppm.gz",
"tt_horp20.ppm.gz", "tt_horp24.ppm.gz", "tt_horp28.ppm.gz", "tt_horp32.ppm.gz",
"tt_horp35.ppm.gz", "tt_horp40.ppm.gz", "tt_horp45.ppm.gz", "tt_horp50.ppm.gz",
"tt_horp55.ppm.gz", "tt_horp60.ppm.gz", "tt_horp65.ppm.gz"
}Definition at line 53 of file plug_ttget.c. Referenced by TTget_URL(). |
|
|
Initial value: {
-40, -36, -32, -28, -24, -20, -16, -12, -8, -4,
-1, 1, 4, 8, 12, 16, 20, 24, 28, 32, 35,
40, 45, 50, 55, 60, 65
}Definition at line 48 of file plug_ttget.c. Referenced by TTget_URL(). |
|
|
Initial value: {
"tt_corm99.ppm.gz", "tt_corm95.ppm.gz", "tt_corm90.ppm.gz", "tt_corm85.ppm.gz",
"tt_corm80.ppm.gz", "tt_corm75.ppm.gz", "tt_corm70.ppm.gz", "tt_corm65.ppm.gz",
"tt_corm60.ppm.gz", "tt_corm55.ppm.gz", "tt_corm50.ppm.gz", "tt_corm45.ppm.gz",
"tt_corm40.ppm.gz", "tt_corm35.ppm.gz", "tt_corm32.ppm.gz", "tt_corm28.ppm.gz",
"tt_corm24.ppm.gz", "tt_corm20.ppm.gz", "tt_corm16.ppm.gz", "tt_corm12.ppm.gz",
"tt_corm08.ppm.gz", "tt_corm04.ppm.gz", "tt_corp00.ppm.gz", "tt_corp04.ppm.gz",
"tt_corp08.ppm.gz", "tt_corp12.ppm.gz", "tt_corp16.ppm.gz", "tt_corp20.ppm.gz",
"tt_corp24.ppm.gz", "tt_corp28.ppm.gz", "tt_corp32.ppm.gz", "tt_corp35.ppm.gz",
"tt_corp40.ppm.gz", "tt_corp45.ppm.gz", "tt_corp50.ppm.gz", "tt_corp55.ppm.gz",
"tt_corp60.ppm.gz", "tt_corp65.ppm.gz"
}Definition at line 17 of file plug_ttget.c. Referenced by TTget_URL(). |
|
|
Initial value: {
-100, -95, -90, -85, -80, -75, -70, -65,
-60, -55, -50, -45, -40, -35, -32, -28,
-24, -20, -16, -12, -8, -4, 0, 4,
8, 12, 16, 20, 24, 28, 32, 35,
40, 45, 50, 55, 60, 65
}Definition at line 10 of file plug_ttget.c. Referenced by TTget_URL(). |
|
|
Definition at line 337 of file plug_ttget.c. Referenced by TTget_recv(). |
|
|
Definition at line 295 of file plug_ttget.c. |
|
|
Definition at line 296 of file plug_ttget.c. Referenced by TTget_main(), and TTget_recv(). |
|
|
Definition at line 261 of file plug_ttget.c. Referenced by PLUGIN_init(), TTget_main(), and TTget_recv(). |
|
|
Definition at line 260 of file plug_ttget.c. Referenced by PLUGIN_init(), and TTget_main(). |
|
|
Definition at line 294 of file plug_ttget.c. Referenced by TTget_main(). |
|
|
Initial value: {
"tt_sag00g.ppm.gz", "tt_sag03.ppm.gz", "tt_sag05.ppm.gz", "tt_sag09.ppm.gz",
"tt_sag13.ppm.gz", "tt_sag17.ppm.gz", "tt_sag21.ppm.gz", "tt_sag25.ppm.gz",
"tt_sag29.ppm.gz", "tt_sag33.ppm.gz", "tt_sag37.ppm.gz", "tt_sag41.ppm.gz",
"tt_sag43.ppm.gz", "tt_sag47.ppm.gz", "tt_sag51.ppm.gz", "tt_sag55.ppm.gz",
"tt_sag59.ppm.gz", "tt_sag61.ppm.gz"
}Definition at line 37 of file plug_ttget.c. Referenced by TTget_URL(). |
|
|
Initial value: {
0, 3, 5, 9, 13, 17, 21, 25, 29, 33,
37, 41, 43, 47, 51, 55, 59, 61
}Definition at line 33 of file plug_ttget.c. Referenced by TTget_URL(). |