Skip to content

AFNI/NIfTI Server

Sections
Personal tools
You are here: Home » AFNI » Documentation

Doxygen Source Code Documentation


Main Page   Alphabetical List   Data Structures   File List   Data Fields   Globals   Search  

afni_driver.c File Reference

#include "afni.h"
#include <X11/keysym.h>
#include "coxplot.h"

Go to the source code of this file.


Data Structures

struct  AFNI_driver_pair
struct  Graph_xy

Typedefs

typedef int dfunc (char *)

Functions

int AFNI_drive_rescan_controller (char *code)
int AFNI_drive_switch_session (char *cmd)
int AFNI_drive_switch_anatomy (char *cmd)
int AFNI_drive_switch_function (char *cmd)
int AFNI_drive_open_window (char *cmd)
int AFNI_drive_close_window (char *cmd)
int AFNI_drive_quit (char *cmd)
int AFNI_drive_save_jpeg (char *cmd)
int AFNI_drive_set_view (char *cmd)
int AFNI_drive_set_dicom_xyz (char *cmd)
int AFNI_drive_set_spm_xyz (char *cmd)
int AFNI_drive_set_ijk (char *cmd)
int AFNI_drive_set_xhairs (char *cmd)
int AFNI_drive_system (char *cmd)
int AFNI_drive_chdir (char *cmd)
int AFNI_drive_open_plugin (char *cmd)
int AFNI_drive_open_graph_xy (char *cmd)
int AFNI_drive_close_graph_xy (char *cmd)
int AFNI_drive_clear_graph_xy (char *cmd)
int AFNI_drive_addto_graph_xy (char *cmd)
int AFNI_drive_open_graph_1D (char *cmd)
int AFNI_drive_close_graph_1D (char *cmd)
int AFNI_drive_clear_graph_1D (char *cmd)
int AFNI_drive_addto_graph_1D (char *cmd)
int AFNI_drive_geom_graph (char *cmd)
int AFNI_drive_add_overlay_color (char *cmd)
int AFNI_drive_set_threshold (char *cmd)
int AFNI_drive_set_threshnew (char *cmd)
int AFNI_drive_set_pbar_number (char *cmd)
int AFNI_drive_set_pbar_sign (char *cmd)
int AFNI_drive_set_pbar_all (char *cmd)
int AFNI_drive_pbar_rotate (char *cmd)
int AFNI_set_func_autorange (char *cmd)
int AFNI_set_func_range (char *cmd)
int AFNI_set_func_visible (char *cmd)
int AFNI_set_func_resam (char *cmd)
int AFNI_sleeper (char *cmd)
int AFNI_define_colorscale (char *cmd)
int AFNI_open_panel (char *cmd)
int AFNI_drive_purge_memory (char *cmd)
int AFNI_redisplay (char *cmd)
int AFNI_driver (char *cmdd)
int AFNI_controller_code_to_index (char *code)
int find_graph_xy_name (char *name)
int find_empty_graph_xy (void)
void kill_graph_xy (MEM_topshell_data *mp)

Variables

AFNI_driver_pair dpair []
int num_Graph_xy = 0
Graph_xy ** Graph_xy_list = NULL

Typedef Documentation

typedef int dfunc(char *)
 

Definition at line 67 of file afni_driver.c.


Function Documentation

int AFNI_controller_code_to_index char *    code
 

Definition at line 262 of file afni_driver.c.

References ENTRY, MAX_CONTROLLERS, and RETURN.

Referenced by AFNI_drive_close_window(), AFNI_drive_open_plugin(), AFNI_drive_open_window(), AFNI_drive_pbar_rotate(), AFNI_drive_rescan_controller(), AFNI_drive_save_jpeg(), AFNI_drive_set_dicom_xyz(), AFNI_drive_set_ijk(), AFNI_drive_set_pbar_all(), AFNI_drive_set_pbar_number(), AFNI_drive_set_pbar_sign(), AFNI_drive_set_spm_xyz(), AFNI_drive_set_threshnew(), AFNI_drive_set_threshold(), AFNI_drive_set_view(), AFNI_drive_set_xhairs(), AFNI_drive_switch_anatomy(), AFNI_drive_switch_function(), AFNI_drive_switch_session(), AFNI_open_panel(), AFNI_set_func_autorange(), AFNI_set_func_range(), AFNI_set_func_resam(), and AFNI_set_func_visible().

00263 {
00264    int ic ;
00265 ENTRY("AFNI_controller_code_to_index") ;
00266    if( code    == NULL || *code   == '\0' ) RETURN(-1) ;
00267    if( code[1] != '\0' && code[1] != '.' && code[1] != ' ' ) RETURN(-1) ;
00268    ic = *code - 'A' ;
00269    if( ic < 0 || ic >= MAX_CONTROLLERS ) ic = -1 ;
00270    RETURN(ic) ;
00271 }

int AFNI_define_colorscale char *    cmd [static]
 

DEFINE_COLORSCALE name num=color num=color ...

Definition at line 2075 of file afni_driver.c.

References PBAR_define_bigmap().

02076 {
02077   return PBAR_define_bigmap( cmd ) ;
02078 }

int AFNI_drive_add_overlay_color char *    cmd [static]
 

ADD_OVERLAY_COLOR colordef colorlab -- 16 Jan 2003 --------------------------------------------------------------------------

Definition at line 1478 of file afni_driver.c.

References AFNI_library_type::dc, DC_add_overlay_color(), ENTRY, GLOBAL_library, INIT_ncolovr, MAX_NCOLOVR, MCW_DC::ovc, OVC_mostest(), and RETURN.

01479 {
01480    char cdef[256]="\0" , clab[256]="\0" ;
01481    int ii ;
01482 
01483 ENTRY("AFNI_drive_add_overlay_color") ;
01484 
01485    sscanf( cmd , "%255s %255s" , cdef,clab ) ;
01486    if( cdef[0] == '\0' || clab[0] == '\0' ) RETURN(-1) ;
01487 
01488    if( GLOBAL_library.dc == NULL ){           /* before X11 started */
01489      if( INIT_ncolovr < MAX_NCOLOVR ){
01490        ii = INIT_ncolovr++ ;
01491        INIT_labovr[ii] = XtNewString(cdef) ;
01492        INIT_colovr[ii] = XtNewString(clab) ;
01493      } else
01494        RETURN(-1) ;
01495    } else {                                   /* after X11 started */
01496      ii = DC_add_overlay_color( GLOBAL_library.dc , cdef , clab ) ;
01497      if( ii < 0 ) RETURN(-1) ;
01498      OVC_mostest( GLOBAL_library.dc->ovc ) ;
01499    }
01500    RETURN(0) ;
01501 }

int AFNI_drive_addto_graph_1D char *    cmd [static]
 

Definition at line 1417 of file afni_driver.c.

References breakup_string(), calloc, ENTRY, find_graph_xy_name(), free, freeup_strings(), malloc, Graph_xy::mp, Graph_xy::ny, plot_strip_addto(), RETURN, strtod(), and tt.

01418 {
01419    int ig, ntok, nx, ny, ii,jj, tt, num_pt, ibot, nadd ;
01420    char **stok = NULL ;
01421    Graph_xy *gxy ;
01422    float **y ;
01423 
01424 ENTRY("AFNI_drive_addto_graph_1D") ;
01425 
01426    /* tokenize the command string */
01427 
01428    ntok = breakup_string( cmd , &stok ) ;
01429    if( ntok <= 0 || stok == NULL ) RETURN(-1) ;
01430 
01431    /* check if this graph name is already in use */
01432 
01433    ig = find_graph_xy_name( stok[0] ) ;
01434    if( ig < 0 || Graph_xy_list[ig]->mp == NULL ){
01435       freeup_strings(ntok,stok) ; RETURN(-1) ;
01436    }
01437    gxy = Graph_xy_list[ig] ;
01438 
01439    /* number of sub-graphs */
01440 
01441    ny = gxy->ny ;
01442 
01443    /* number of points to add to each sub-graph */
01444 
01445    nadd = (ntok-1)/ny ;
01446    if( nadd < 1 ){ freeup_strings(ntok,stok); RETURN(-1); }
01447 
01448    /* make space for incoming data */
01449 
01450    y = (float **) malloc( sizeof(float *)*ny ) ;
01451    for( jj=0 ; jj < ny ; jj++ )
01452       y[jj] = (float *) calloc(nadd,sizeof(float)) ;
01453 
01454    /* convert incoming tokens to numbers */
01455 
01456    tt = 1 ;                            /* token index */
01457    for( ii=0 ; ii < nadd ; ii++ ){
01458       for( jj=0 ; jj < ny ; jj++ )
01459          y[jj][ii] = strtod( stok[tt++] , NULL ) ;
01460    }
01461 
01462    /***** graphing! *****/
01463 
01464    plot_strip_addto( gxy->mp , nadd , y ) ;
01465 
01466    /* cleanup */
01467 
01468    for( jj=0 ; jj < ny ; jj++ ) free(y[jj]) ;
01469    free(y) ; freeup_strings(ntok,stok) ;
01470 
01471    RETURN(0) ;
01472 }

int AFNI_drive_addto_graph_xy char *    cmd [static]
 

Definition at line 1188 of file afni_driver.c.

References breakup_string(), calloc, ENTRY, find_graph_xy_name(), free, freeup_strings(), Graph_xy::last_x, Graph_xy::last_y, malloc, Graph_xy::mp, Graph_xy::num_pt, Graph_xy::ny, plot_ts_addto(), RETURN, strtod(), and tt.

01189 {
01190    int ig , ntok , nx , ny , ii,jj , tt , num_pt , ibot ;
01191    char **stok = NULL ;
01192    Graph_xy *gxy ;
01193    float *x , **y ;
01194 
01195 ENTRY("AFNI_drive_addto_graph_xy") ;
01196 
01197    /* tokenize the command string */
01198 
01199    ntok = breakup_string( cmd , &stok ) ;
01200    if( ntok <= 0 || stok == NULL ) RETURN(-1) ;
01201 
01202    /* check if this graph name is already in use */
01203 
01204    ig = find_graph_xy_name( stok[0] ) ;
01205    if( ig < 0 || Graph_xy_list[ig]->mp == NULL ){
01206       freeup_strings(ntok,stok) ; RETURN(-1) ;
01207    }
01208    gxy = Graph_xy_list[ig] ;
01209 
01210    /* number of sub-graphs */
01211 
01212    ny = gxy->ny ;
01213 
01214    /* number of points to add to each sub-graph */
01215 
01216    nx = (ntok-1)/(ny+1) ;
01217    if( nx < 1 ){ freeup_strings(ntok,stok); RETURN(-1); }
01218 
01219    /* attach to last_x and last_y? */
01220 
01221    num_pt = gxy->num_pt ;
01222    if( num_pt > 0 ) nx++ ;  /* need 1 extra place for last_x and last_y */
01223 
01224    x = (float *) calloc(nx,sizeof(float)) ;
01225    y = (float **) malloc( sizeof(float *)*ny ) ;
01226    for( jj=0 ; jj < ny ; jj++ )
01227       y[jj] = (float *) calloc(nx,sizeof(float)) ;
01228 
01229    /* put last_x and last_y into graphing data, if needed */
01230 
01231    if( num_pt > 0 ){
01232       x[0] = gxy->last_x ;
01233       for( jj=0 ; jj < ny ; jj++ ) y[jj][0] = gxy->last_y[jj] ;
01234       ibot = 1 ;
01235    } else {
01236       ibot = 0 ;
01237    }
01238 
01239    /* parse tokens into numbers for graphing */
01240 
01241    tt = 1 ;                            /* token index */
01242    for( ii=ibot ; ii < nx ; ii++ ){
01243       x[ii] = strtod( stok[tt++] , NULL ) ;
01244       for( jj=0 ; jj < ny ; jj++ )
01245          y[jj][ii] = strtod( stok[tt++] , NULL ) ;
01246    }
01247 
01248    /* save new last_x and last_y */
01249 
01250    gxy->last_x = x[nx-1] ;
01251    for( jj=0 ; jj < ny ; jj++ ) gxy->last_y[jj] = y[jj][nx-1] ;
01252 
01253    /**** graphing! ****/
01254 
01255    plot_ts_addto( gxy->mp , nx , x , -ny , y ) ;
01256 
01257    /* cleanup */
01258 
01259    gxy->num_pt += nx ;  /* number of points in each sub-graph so far */
01260 
01261    for( jj=0 ; jj < ny ; jj++ ) free(y[jj]) ;
01262    free(y) ; free(x) ; freeup_strings(ntok,stok) ;
01263 
01264    RETURN(0) ;
01265 }

int AFNI_drive_chdir char *    cmd [static]
 

Change working directory.

Definition at line 247 of file afni_driver.c.

00248 {
00249    return chdir( cmd ) ;
00250 }

int AFNI_drive_clear_graph_1D char *    cmd [static]
 

Definition at line 1388 of file afni_driver.c.

References breakup_string(), ENTRY, find_graph_xy_name(), freeup_strings(), mp, Graph_xy::mp, plot_strip_clear(), and RETURN.

01389 {
01390    int ig , ntok , ii ;
01391    char **stok = NULL ;
01392 
01393 ENTRY("AFNI_drive_clear_graph_1D") ;
01394 
01395    /* tokenize the command string */
01396 
01397    ntok = breakup_string( cmd , &stok ) ;
01398    if( ntok <= 0 || stok == NULL ) RETURN(-1) ;
01399 
01400    /* check if this graph name is already in use */
01401 
01402    ig = find_graph_xy_name( stok[0] ) ;
01403    freeup_strings(ntok,stok) ;
01404    if( ig < 0 || Graph_xy_list[ig]->mp == NULL ) RETURN(-1) ;
01405 
01406    /* do the clearance work */
01407 
01408    plot_strip_clear( Graph_xy_list[ig]->mp ) ;  /* coxplot/plot_strip.c */
01409 
01410    RETURN(0) ;
01411 }

int AFNI_drive_clear_graph_xy char *    cmd [static]
 

Definition at line 1154 of file afni_driver.c.

References breakup_string(), ENTRY, find_graph_xy_name(), freeup_strings(), MEM_topshell_data::mp, mp, Graph_xy::mp, Graph_xy::num_mpinit, Graph_xy::num_pt, redraw_topshell(), RETURN, and TRUNC_MEMPLOT.

01155 {
01156    int ig , ntok ;
01157    char **stok = NULL ;
01158 
01159 ENTRY("AFNI_drive_clear_graph_xy") ;
01160 
01161    /* tokenize the command string */
01162 
01163    ntok = breakup_string( cmd , &stok ) ;
01164    if( ntok <= 0 || stok == NULL ) RETURN(-1) ;
01165 
01166    /* check if this graph name is already in use */
01167 
01168    ig = find_graph_xy_name( stok[0] ) ;
01169    freeup_strings(ntok,stok) ;
01170    if( ig < 0 || Graph_xy_list[ig]->mp == NULL ) RETURN(-1) ;
01171 
01172    /* cut off the graph lines since the initial stuff */
01173 
01174    TRUNC_MEMPLOT( Graph_xy_list[ig]->mp->mp ,
01175                   Graph_xy_list[ig]->num_mpinit ) ;
01176 
01177    /* show it again, Sam (but the data part will be gone) */
01178 
01179    redraw_topshell( Graph_xy_list[ig]->mp ) ;
01180    Graph_xy_list[ig]->num_pt = 0 ;  /* number of points plotted thus far */
01181    RETURN(0) ;
01182 }

int AFNI_drive_close_graph_1D char *    cmd [static]
 

Definition at line 1271 of file afni_driver.c.

References AFNI_drive_close_graph_xy().

01272 {
01273   return AFNI_drive_close_graph_xy( cmd ) ;
01274 }

int AFNI_drive_close_graph_xy char *    cmd [static]
 

Definition at line 1128 of file afni_driver.c.

References breakup_string(), ENTRY, find_graph_xy_name(), freeup_strings(), mp, Graph_xy::mp, plotkill_topshell(), and RETURN.

Referenced by AFNI_drive_close_graph_1D().

01129 {
01130    int ig , ntok ;
01131    char **stok = NULL ;
01132 
01133 ENTRY("AFNI_drive_close_graph_xy") ;
01134 
01135    /* tokenize the command string */
01136 
01137    ntok = breakup_string( cmd , &stok ) ;
01138    if( ntok <= 0 || stok == NULL ) RETURN(-1) ;
01139 
01140    /* check if this graph name is already in use */
01141 
01142    ig = find_graph_xy_name( stok[0] ) ;
01143    freeup_strings(ntok,stok) ;
01144    if( ig < 0 || Graph_xy_list[ig]->mp == NULL ) RETURN(-1) ;
01145 
01146    plotkill_topshell( Graph_xy_list[ig]->mp ) ; /* will call kill_graph_xy */
01147    RETURN(0) ;
01148 }

int AFNI_drive_close_window char *    cmd [static]
 

Definition at line 730 of file afni_driver.c.

References AFNI_controller_code_to_index(), AFNI_count_controllers(), CLOSE_CONTROLLER, AFNI_library_type::controllers, drive_MCW_grapher(), drive_MCW_imseq(), ENTRY, Three_D_View::g123, Three_D_View::g231, Three_D_View::g312, GLOBAL_library, graDR_destroy, IM3D_OPEN, isqDR_destroy, RETURN, Three_D_View::s123, Three_D_View::s231, Three_D_View::s312, AFNI_widget_set::top_shell, and Three_D_View::vwid.

00731 {
00732    int ic ;
00733    Three_D_View *im3d ;
00734 
00735 ENTRY("AFNI_drive_close_window") ;
00736 
00737    /* make sure the controller itself is open */
00738 
00739    ic = AFNI_controller_code_to_index( cmd ) ;
00740    if( ic < 0 ) ic = 0 ;
00741 
00742    im3d = GLOBAL_library.controllers[ic] ;
00743    if( !IM3D_OPEN(im3d) ) RETURN(-1) ;       /* that was easy */
00744 
00745    if( strlen(cmd) < 3 ){                    /* close the controller */
00746       if( AFNI_count_controllers() > 1 ){    /* but only if there is */
00747          CLOSE_CONTROLLER(im3d); RETURN(0);  /* at least 1 more open */
00748       }
00749       RETURN(-1) ;                           /* can't close last controller */
00750    }
00751 
00752    /* close a graph or image window */
00753 
00754         if( strstr(cmd,"axialimage") != NULL )
00755           drive_MCW_imseq( im3d->s123 , isqDR_destroy , NULL ) ;
00756 
00757    else if( strstr(cmd,"sagittalimage") != NULL )
00758           drive_MCW_imseq( im3d->s231 , isqDR_destroy , NULL ) ;
00759 
00760    else if( strstr(cmd,"coronalimage") != NULL )
00761           drive_MCW_imseq( im3d->s312 , isqDR_destroy , NULL ) ;
00762 
00763    else if( strstr(cmd,"axialgraph") != NULL )
00764           drive_MCW_grapher( im3d->g123 , graDR_destroy , NULL ) ;
00765 
00766    else if( strstr(cmd,"sagittalgraph") != NULL )
00767           drive_MCW_grapher( im3d->g231 , graDR_destroy , NULL ) ;
00768 
00769    else if( strstr(cmd,"coronalgraph") != NULL )
00770           drive_MCW_grapher( im3d->g312 , graDR_destroy , NULL ) ;
00771 
00772    else
00773           RETURN(-1) ;
00774 
00775    XmUpdateDisplay( im3d->vwid->top_shell ) ;
00776    RETURN(0) ;
00777 }

int AFNI_drive_geom_graph char *    cmd [static]
 

Definition at line 976 of file afni_driver.c.

References AFNI_decode_geom(), breakup_string(), ENTRY, find_graph_xy_name(), freeup_strings(), Graph_xy::mp, RETURN, and MEM_topshell_data::top.

00977 {
00978    int ntok , ig ;
00979    char **stok=NULL ;
00980    char *gname , *cpt ;
00981    Graph_xy *gxy ;
00982    int gww=-1,ghh=-1,gxx=-1,gyy=-1 ;
00983 
00984 ENTRY("AFNI_drive_geom_graph") ;
00985 
00986    /* tokenize the command string */
00987 
00988    ntok = breakup_string( cmd , &stok ) ;
00989    if( ntok <= 0 || stok == NULL ) RETURN(-1) ;
00990 
00991    /* check if this graph name is already in use */
00992 
00993    ig = find_graph_xy_name( stok[0] ) ;
00994    freeup_strings(ntok,stok) ;
00995    if( ig < 0 || Graph_xy_list[ig]->mp == NULL ) RETURN(-1) ;
00996    gxy = Graph_xy_list[ig] ;
00997 
00998    cpt = strstr(cmd,"geom=") ;
00999    if( cpt == NULL ) cpt = strstr(cmd,"geom:") ;
01000    if( cpt == NULL || strlen(cpt) < 7 ) RETURN(-1) ;
01001 
01002    AFNI_decode_geom( cpt+5 , &gww,&ghh,&gxx,&gyy ) ;
01003 
01004    ig = -1 ;
01005    if( gxx >= 0 && gyy >= 0 ){
01006      XtVaSetValues( gxy->mp->top , XmNx,gxx    , XmNy,gyy     , NULL ); ig=0;
01007    }
01008    if( gww > 0 && ghh > 0 ){
01009      XtVaSetValues( gxy->mp->top , XmNwidth,gww, XmNheight,ghh, NULL ); ig=0;
01010    }
01011 
01012    RETURN(ig) ;
01013 }

int AFNI_drive_open_graph_1D char *    cmd [static]
 

Definition at line 1281 of file afni_driver.c.

References breakup_string(), calloc, AFNI_library_type::dc, MCW_DC::display, ENTRY, find_empty_graph_xy(), find_graph_xy_name(), free, freeup_strings(), GLOBAL_library, Graph_xy::gname, kill_graph_xy(), Graph_xy::last_y, malloc, MCW_strncpy, Graph_xy::mp, Graph_xy::num_pt, Graph_xy::ny, plot_strip_init(), RETURN, strtod(), THD_MAX_NAME, Graph_xy::xbot, Graph_xy::xtop, Graph_xy::ybot, and Graph_xy::ytop.

01282 {
01283    int ntok , ig , ii ;
01284    char **stok=NULL ;
01285 
01286    char *gname , *toplabel=NULL , *xlabel=NULL , *ylabel=NULL ;
01287    int   ny=1 , nx=500 ;
01288    float dx=1.0 , ybot=0.0,ytop=1.0 ;
01289    char **yname=NULL ;
01290 
01291    Graph_xy *gxy ;
01292 
01293 ENTRY("AFNI_drive_open_graph_1D") ;
01294 
01295    /* tokenize the command string */
01296 
01297    ntok = breakup_string( cmd , &stok ) ;
01298    if( ntok <= 0 || stok == NULL ) RETURN(-1) ;
01299 
01300    /* check if this graph name is already in use */
01301 
01302    gname = stok[0] ;
01303    ig = find_graph_xy_name( gname ) ;
01304    if( ig >= 0 ){
01305       freeup_strings(ntok,stok) ; RETURN(-1) ;   /* already used = bad */
01306    }
01307 
01308 #if 0
01309 { int qq ;
01310   fprintf(stderr,"AFNI_drive_open_graph_1D tokens:\n") ;
01311   for( qq=0 ; qq < ntok ; qq++ ) fprintf(stderr," %2d:%s\n",qq,stok[qq]); }
01312 #endif
01313 
01314    /* create a graph */
01315 
01316    ig = find_empty_graph_xy() ;
01317 
01318    Graph_xy_list[ig] = gxy = (Graph_xy *) malloc(sizeof(Graph_xy)) ;
01319 
01320    MCW_strncpy( gxy->gname , gname , THD_MAX_NAME ) ;
01321 
01322    /* parse values out of the tokens */
01323 
01324    if( ntok > 1 ) toplabel = stok[1] ;
01325 
01326    if( ntok > 2 ){
01327       int qq = strtol(stok[2],NULL,10) ;
01328       if( qq >= 10 ) nx = qq ;
01329    }
01330 
01331    if( ntok > 3 ){
01332       float qq = strtod(stok[3],NULL) ;
01333       if( qq > 0.0 ) dx = qq ;
01334    }
01335 
01336    if( ntok > 4 ) xlabel = stok[4] ;
01337 
01338    if( ntok > 5 ){
01339       int qq = strtol(stok[5],NULL,10) ;
01340       if( qq > 1 ) ny = qq ;
01341    }
01342 
01343    if( ntok > 6 ) ybot = strtod(stok[6],NULL) ;
01344    if( ntok > 7 ) ytop = strtod(stok[7],NULL) ;
01345    if( ybot == ytop )    { ytop = ybot+1.0 ; }
01346    else if( ybot > ytop ){ float qq = ybot; ybot = ytop; ytop = qq ; }
01347 
01348    if( ntok > 8 ) ylabel = stok[8] ;
01349 
01350    if( ntok > 9 ){
01351       int qq ;
01352       yname = (char **) calloc( ny , sizeof(char *) ) ;
01353       for( qq=0 ; qq < ny && qq+9 < ntok ; qq++ ) yname[qq] = stok[qq+9] ;
01354    }
01355 
01356    /* put values into graph struct */
01357 
01358    gxy->xbot = 0.0  ; gxy->xtop = nx*dx ;
01359    gxy->ybot = ybot ; gxy->ytop = ytop  ; gxy->ny = ny ;
01360 
01361    gxy->num_pt = 0.0 ;
01362 
01363    /* create the actual graph */
01364 
01365    gxy->mp = plot_strip_init( GLOBAL_library.dc->display ,
01366                               nx , dx ,
01367                               -ny , ybot , ytop ,
01368                               xlabel , ylabel ,
01369                               toplabel , yname , kill_graph_xy ) ;
01370 
01371    freeup_strings(ntok,stok) ;
01372    if( yname != NULL ) free(yname) ;
01373 
01374    if( gxy->mp == NULL ){         /* should not happen */
01375       free(Graph_xy_list[ig]) ; Graph_xy_list[ig] = NULL ;
01376       RETURN(-1) ;
01377    }
01378 
01379    gxy->last_y = NULL ;  /* not used for this graph type */
01380 
01381    RETURN(0) ;
01382 }

int AFNI_drive_open_graph_xy char *    cmd [static]
 

Definition at line 1020 of file afni_driver.c.

References breakup_string(), calloc, AFNI_library_type::dc, MCW_DC::display, ENTRY, find_empty_graph_xy(), find_graph_xy_name(), free, freeup_strings(), GLOBAL_library, Graph_xy::gname, kill_graph_xy(), Graph_xy::last_y, MCW_strncpy, MEMPLOT_NLINE, MEM_topshell_data::mp, Graph_xy::mp, Graph_xy::num_mpinit, Graph_xy::num_pt, Graph_xy::ny, plot_ts_init(), RETURN, strtod(), THD_MAX_NAME, Graph_xy::xbot, Graph_xy::xtop, Graph_xy::ybot, and Graph_xy::ytop.

01021 {
01022    int ntok , ig ;
01023    char **stok=NULL ;
01024 
01025    char *gname , *toplabel=NULL , *xlabel=NULL , *ylabel=NULL ;
01026    int   ny=1 ;
01027    float xbot=0.0,xtop=1.0 , ybot=0.0,ytop=1.0 ;
01028    char **yname=NULL ;
01029 
01030    Graph_xy *gxy ;
01031 
01032 ENTRY("AFNI_drive_open_graph_xy") ;
01033 
01034    /* tokenize the command string */
01035 
01036    ntok = breakup_string( cmd , &stok ) ;
01037    if( ntok <= 0 || stok == NULL ) RETURN(-1) ;
01038 
01039    /* check if this graph name is already in use */
01040 
01041    gname = stok[0] ;
01042    ig = find_graph_xy_name( gname ) ;
01043    if( ig >= 0 ){
01044       freeup_strings(ntok,stok) ; RETURN(-1) ;   /* already used = bad */
01045    }
01046 
01047    /* create a graph */
01048 
01049    ig = find_empty_graph_xy() ;
01050 
01051    Graph_xy_list[ig] = gxy = (Graph_xy *) calloc(1,sizeof(Graph_xy)) ;
01052 
01053    MCW_strncpy( gxy->gname , gname , THD_MAX_NAME ) ;
01054 
01055 #if 0
01056 { int qq ;
01057   fprintf(stderr,"AFNI_drive_open_graph_xy tokens:\n") ;
01058   for( qq=0 ; qq < ntok ; qq++ ) fprintf(stderr," %2d:%s\n",qq,stok[qq]); }
01059 #endif
01060 
01061    /* parse values out of the tokens */
01062 
01063    if( ntok > 1 ) toplabel = stok[1] ;
01064 
01065    if( ntok > 2 ) xbot = strtod(stok[2],NULL) ;
01066    if( ntok > 3 ) xtop = strtod(stok[3],NULL) ;
01067    if( xbot == xtop )    { xtop = xbot+1.0 ; }
01068    else if( xbot > xtop ){ float qq = xbot; xbot = xtop; xtop = qq ; }
01069 
01070    if( ntok > 4 ) xlabel = stok[4] ;
01071 
01072    if( ntok > 5 ){
01073       int qq = strtol(stok[5],NULL,10) ;
01074       if( qq > 1 ) ny = qq ;
01075    }
01076 
01077    if( ntok > 6 ) ybot = strtod(stok[6],NULL) ;
01078    if( ntok > 7 ) ytop = strtod(stok[7],NULL) ;
01079    if( ybot == ytop )    { ytop = ybot+1.0 ; }
01080    else if( ybot > ytop ){ float qq = ybot; ybot = ytop; ytop = qq ; }
01081 
01082    if( ntok > 8 ) ylabel = stok[8] ;
01083 
01084    if( ntok > 9 ){
01085       int qq ;
01086       yname = (char **) calloc( ny , sizeof(char *) ) ;
01087       for( qq=0 ; qq < ny && qq+9 < ntok ; qq++ ) yname[qq] = stok[qq+9] ;
01088    }
01089 
01090    /* put values into graph struct */
01091 
01092    gxy->xbot = xbot ; gxy->xtop = xtop ;
01093    gxy->ybot = ybot ; gxy->ytop = ytop ; gxy->ny = ny ;
01094 
01095    gxy->num_pt = 0 ;  /* number of points plotted thus far */
01096 
01097    /* create the actual graph */
01098 
01099    gxy->mp = plot_ts_init( GLOBAL_library.dc->display ,
01100                            xbot , xtop ,
01101                            -ny , ybot , ytop ,
01102                            xlabel , ylabel ,
01103                            toplabel , yname , kill_graph_xy ) ;
01104 
01105    freeup_strings(ntok,stok) ;
01106    if( yname != NULL ) free(yname) ;
01107 
01108    if( gxy->mp == NULL ){         /* should not happen */
01109       free(Graph_xy_list[ig]) ; Graph_xy_list[ig] = NULL ;
01110       RETURN(-1) ;
01111    }
01112 
01113    /* number of lines plotted so far (labels, etc.) */
01114 
01115    gxy->num_mpinit = MEMPLOT_NLINE(gxy->mp->mp) ;
01116 
01117    /* place to store last location plotted */
01118 
01119    gxy->last_y = (float *) calloc(ny,sizeof(float)) ;
01120 
01121    RETURN(0) ;
01122 }

int AFNI_drive_open_plugin char *    cmd [static]
 

Definition at line 784 of file afni_driver.c.

References AFNI_controller_code_to_index(), AFNI_decode_geom(), AFNI_library_type::controllers, ENTRY, GLOBAL_library, AFNI_widget_set::nplugbut, PLUG_startup_plugin_CB(), AFNI_widget_set::plugbut, AFNI_widget_set::plugint, AFNI_widget_set::pluglab, RETURN, AFNI_widget_set::top_shell, and Three_D_View::vwid.

Referenced by AFNI_drive_open_window().

00785 {
00786    int ic , ipl , ll , pl , qq ;
00787    Three_D_View *im3d ;
00788    char *cpt ;
00789    int gww=-1,ghh=-1,gxx=-1,gyy=-1 ;
00790 
00791    int      npbut              ;       /* how many plugins */
00792    char **  pluglab            ;       /* their labels     */
00793    PLUGIN_interface ** plugint ;       /* their interfaces */
00794 
00795 ENTRY("AFNI_drive_open_plugin") ;
00796 
00797    /* the controller is always good,
00798       since we are called from a place that just made sure of that */
00799 
00800    ic = AFNI_controller_code_to_index( cmd ) ;
00801    if( ic < 0 ) ic = 0 ;
00802    im3d = GLOBAL_library.controllers[ic] ;
00803 
00804    cpt = strstr(cmd,"plugin.") ;
00805    if( cpt == NULL || strlen(cpt) < 9 ) RETURN(-1) ;
00806    cpt += 7 ;  /* start of plugin name */
00807    pl   = strlen(cpt) ;
00808 
00809    /* get list of plugins */
00810 
00811    npbut   = im3d->vwid->nplugbut; if( npbut < 1 ) RETURN(-1) ;
00812    pluglab = im3d->vwid->pluglab ;
00813    plugint = im3d->vwid->plugint ;
00814 
00815    /* check name after plugin. vs. list */
00816 
00817    for( ipl=0 ; ipl < npbut ; ipl++ ){
00818       for( ll=strlen(pluglab[ipl]) ;   /* truncate trailing blanks */
00819            ll >= 0 && isspace(pluglab[ipl][ll]) ; ll-- ) ; /* nada */
00820       if( ll < 0 ) continue ;                        /* all blanks?! ERROR */
00821       if( pl < ll ) continue ;                       /* too short to match */
00822       for( qq=0 ; qq < ll ; qq++ )                   /* match each nonblank */
00823          if( !isspace(pluglab[ipl][qq]) && cpt[qq]!=pluglab[ipl][qq] ) break ;
00824       if( qq == ll ) break ;  /* found a match */
00825    }
00826 
00827    if( ipl >= npbut ) RETURN(-1) ;  /* no plugin found with this name */
00828 
00829    /* try to start the plugin (same callback as pressing the plugin's button) */
00830 
00831    PLUG_startup_plugin_CB( im3d->vwid->plugbut[ipl] , plugint[ipl] , NULL ) ;
00832 
00833    /* find geom=..., if present */
00834 
00835    cpt = strstr(cmd,"geom=") ;
00836    if( cpt == NULL ) cpt = strstr(cmd,"geom:") ;
00837    if( cpt != NULL )
00838       AFNI_decode_geom( cpt+5 , &gww,&ghh,&gxx,&gyy ) ;
00839 
00840    if( gxx >= 0                         &&
00841        gyy >= 0                         &&
00842        plugint[ipl]->wid        != NULL &&
00843        plugint[ipl]->wid->shell != NULL   ){
00844 
00845        XtVaSetValues( plugint[ipl]->wid->shell,
00846                       XmNx , gxx , XmNy , gyy , NULL ) ;
00847    }
00848 
00849    XmUpdateDisplay( im3d->vwid->top_shell ) ;
00850    RETURN(0) ;
00851 }

int AFNI_drive_open_window char *    cmd [static]
 

Definition at line 460 of file afni_driver.c.

References AFNI_controller_clonify(), AFNI_controller_code_to_index(), AFNI_decode_geom(), AFNI_drive_open_plugin(), AFNI_initialize_controller(), AFNI_initialize_view(), AFNI_make_controller(), AFNI_view_xyz_CB(), AFNI_library_type::controllers, MCW_grapher::dc, MCW_imseq::dc, Three_D_View::dc, DC_find_overlay_color(), drive_MCW_grapher(), drive_MCW_imseq(), ENTRY, MCW_grapher::fdw_graph, FRAC_MIN, Three_D_View::g123, Three_D_View::g231, Three_D_View::g312, GLOBAL_library, GRA_handle_keypress(), GRA_timer_stop(), graDR_setmatrix, graDR_setpinbot, graDR_setpinnum, AFNI_imaging_widgets::graph_xyz_pb, AFNI_imaging_widgets::graph_yzx_pb, AFNI_imaging_widgets::graph_zxy_pb, IM3D_OPEN, IM3D_VALID, AFNI_widget_set::imag, AFNI_imaging_widgets::image_xyz_pb, AFNI_imaging_widgets::image_yzx_pb, AFNI_imaging_widgets::image_zxy_pb, isq, ISQ_handle_keypress(), isqDR_setifrac, isqDR_setmontage, isqDR_setopacity, key, mat, MIN_PIN, MONT_NMAX, mp, OPEN_CONTROLLER, RETURN, Three_D_View::s123, Three_D_View::s231, Three_D_View::s312, MCW_DC::screen_num, strtod(), AFNI_widget_set::top_shell, Three_D_View::vwid, and MCW_imseq::wtop.

00461 {
00462    int ic ;
00463    Three_D_View *im3d ;
00464    char *cpt ;
00465    int gww=-1,ghh=-1,gxx=-1,gyy=-1 ;
00466    MCW_imseq   *isq=NULL ;
00467    MCW_grapher *gra=NULL ;
00468 
00469 ENTRY("AFNI_drive_open_window") ;
00470 
00471    /* make sure the controller itself is open */
00472 
00473    ic = AFNI_controller_code_to_index( cmd ) ;
00474    if( ic < 0 ) ic = 0 ;
00475 
00476    im3d = GLOBAL_library.controllers[ic] ;
00477    if( !IM3D_VALID(im3d) ){                  /* try to create it */
00478       AFNI_make_controller( ic ) ;
00479       im3d = GLOBAL_library.controllers[ic] ;
00480       if( !IM3D_VALID(im3d) ) RETURN(-1) ;   /* should never happen */
00481    }
00482 
00483    if( !IM3D_OPEN(im3d) ){                   /* make sure is visible */
00484       OPEN_CONTROLLER(im3d) ;
00485       AFNI_initialize_controller( im3d ) ;   /* decide what to see */
00486       AFNI_initialize_view( NULL , im3d ) ;  /* set up to see it */
00487       AFNI_controller_clonify() ;
00488    }
00489 
00490    if( strlen(cmd) < 3 ) RETURN(0) ;         /* no commands? */
00491 
00492    /* 13 Nov 2001: plugins are done in a separate function */
00493 
00494 #ifdef ALLOW_PLUGINS
00495    if( strstr(cmd,"plugin.") != NULL ){
00496       ic = AFNI_drive_open_plugin( cmd ) ;
00497       RETURN(ic) ;
00498    }
00499 #endif
00500 
00501    /* open a graph or image window */
00502 
00503         if( strstr(cmd,"axialimage") != NULL ){
00504           AFNI_view_xyz_CB( im3d->vwid->imag->image_xyz_pb, im3d, NULL ) ;
00505           isq = im3d->s123 ;
00506 
00507    } else if( strstr(cmd,"sagittalimage") != NULL ){
00508           AFNI_view_xyz_CB( im3d->vwid->imag->image_yzx_pb, im3d, NULL ) ;
00509           isq = im3d->s231 ;
00510 
00511    } else if( strstr(cmd,"coronalimage") != NULL ){
00512           AFNI_view_xyz_CB( im3d->vwid->imag->image_zxy_pb, im3d, NULL ) ;
00513           isq = im3d->s312 ;
00514 
00515    } else if( strstr(cmd,"axialgraph") != NULL ){
00516           AFNI_view_xyz_CB( im3d->vwid->imag->graph_xyz_pb, im3d, NULL ) ;
00517           gra = im3d->g123 ;
00518 
00519    } else if( strstr(cmd,"sagittalgraph") != NULL ){
00520           AFNI_view_xyz_CB( im3d->vwid->imag->graph_yzx_pb, im3d, NULL ) ;
00521           gra = im3d->g231 ;
00522 
00523    } else if( strstr(cmd,"coronalgraph") != NULL ){
00524           AFNI_view_xyz_CB( im3d->vwid->imag->graph_zxy_pb, im3d, NULL ) ;
00525           gra = im3d->g312 ;
00526    }
00527    XmUpdateDisplay( im3d->vwid->top_shell ) ;
00528 
00529    /* find geom=..., if present */
00530 
00531    cpt = strstr(cmd,"geom=") ;
00532    if( cpt == NULL ) cpt = strstr(cmd,"geom:") ;
00533    if( cpt != NULL )
00534      AFNI_decode_geom( cpt+5 , &gww,&ghh,&gxx,&gyy ) ;
00535 
00536    /*--- opened an image viewer: maybe modify it ---*/
00537 
00538    if( isq != NULL ){
00539 
00540       /* geometry */
00541 
00542       if( gxx >= 0 && gyy >= 0 )
00543         XtVaSetValues( isq->wtop, XmNx, gxx, XmNy, gyy, NULL ) ;
00544       if( gww > 0 && ghh > 0 )
00545         XtVaSetValues( isq->wtop, XmNwidth, gww, XmNheight, ghh, NULL ) ;
00546 
00547       /* image fraction */
00548 
00549       cpt = strstr(cmd,"ifrac=") ;
00550       if( cpt == NULL ) cpt = strstr(cmd,"ifrac:") ;
00551       if( cpt != NULL ){
00552         float ifrac = strtod( cpt+6 , NULL ) ;
00553         if( ifrac >= FRAC_MIN && ifrac <= 1.0 )
00554           drive_MCW_imseq( isq, isqDR_setifrac, (XtPointer)(&ifrac) ) ;
00555       }
00556 
00557       /* montage */
00558 
00559       cpt = strstr(cmd,"mont=") ;
00560       if( cpt == NULL ) cpt = strstr(cmd,"mont:") ;
00561       if( cpt != NULL ){
00562         int mww=-1 , mhh=-1 , msp=-1 , mgap=-1 , nn ;
00563         char mcol[128] = "\0" ;
00564 
00565         nn = sscanf( cpt+5 , "%dx%d:%d:%d:%s" , &mww,&mhh,&msp,&mgap,mcol );
00566 
00567         if( nn >= 2 && mww >= 1 && mww <= MONT_NMAX && mhh >= 1 && mhh <= MONT_NMAX ){
00568           int mp[5] ;
00569           mp[0] = mww ; mp[1] = mhh ; mp[2] = msp ; mp[3] = mgap ;
00570           mp[4] = DC_find_overlay_color(im3d->dc,mcol);
00571           drive_MCW_imseq( isq , isqDR_setmontage , (XtPointer)mp ) ;
00572         }
00573       }
00574 
00575       /* iconify [06 Aug 2002] */
00576 
00577       cpt = strstr(cmd,"iconi") ;
00578       if( cpt != NULL ){
00579         XIconifyWindow( XtDisplay(isq->wtop) ,
00580                          XtWindow(isq->wtop)  ,
00581                          isq->dc->screen_num   ) ;
00582       }
00583 
00584       /* opacity [21 Jan 2003] */
00585 
00586       cpt = strstr(cmd,"opacity=") ;
00587       if( cpt == NULL ) cpt = strstr(cmd,"opacity:") ;
00588       if( cpt != NULL ){
00589         int opaval = -1 ;
00590         sscanf( cpt+8 , "%d" , &opaval ) ;
00591         drive_MCW_imseq( isq , isqDR_setopacity , (XtPointer)opaval ) ;
00592       }
00593 
00594       /* keypress [18 Feb 2005] */
00595 
00596       cpt = strstr(cmd,"keypress=") ;
00597       if( cpt == NULL ) cpt = strstr(cmd,"keypress:") ;
00598       if( cpt != NULL ){
00599         unsigned long key ;
00600         cpt += 9 ;
00601         if( *cpt == '\'' || *cpt == '\"' ) cpt++ ;
00602              if( strncmp(cpt,"XK_Left"     , 7) == 0 ) key = XK_Left     ;
00603         else if( strncmp(cpt,"XK_Right"    , 8) == 0 ) key = XK_Right    ;
00604         else if( strncmp(cpt,"XK_Down"     , 7) == 0 ) key = XK_Down     ;
00605         else if( strncmp(cpt,"XK_Up"       , 5) == 0 ) key = XK_Up       ;
00606         else if( strncmp(cpt,"XK_Page_Up"  ,10) == 0 ) key = XK_Page_Up  ;
00607         else if( strncmp(cpt,"XK_Page_Down",12) == 0 ) key = XK_Page_Down;
00608         else if( strncmp(cpt,"XK_Delete"   , 9) == 0 ) key = XK_Delete   ;
00609         else if( strncmp(cpt,"XK_Home"     , 7) == 0 ) key = XK_Home     ;
00610         else if( strncmp(cpt,"XK_F2"       , 5) == 0 ) key = XK_F2       ;
00611         else if( strncmp(cpt,"XK_F3"       , 5) == 0 ) key = XK_F3       ;
00612         else if( strncmp(cpt,"XK_F4"       , 5) == 0 ) key = XK_F4       ;
00613         else if( strncmp(cpt,"XK_F5"       , 5) == 0 ) key = XK_F5       ;
00614         else if( strncmp(cpt,"XK_F6"       , 5) == 0 ) key = XK_F6       ;
00615         else if( strncmp(cpt,"XK_F7"       , 5) == 0 ) key = XK_F7       ;
00616         else if( strncmp(cpt,"XK_F8"       , 5) == 0 ) key = XK_F8       ;
00617         else if( strncmp(cpt,"XK_F9"       , 5) == 0 ) key = XK_F9       ;
00618         else if( strncmp(cpt,"XK_F10"      , 6) == 0 ) key = XK_F10      ;
00619         else if( strncmp(cpt,"XK_F11"      , 6) == 0 ) key = XK_F11      ;
00620         else if( strncmp(cpt,"XK_F12"      , 6) == 0 ) key = XK_F12      ;
00621         else                                           key = *cpt        ;
00622         ISQ_handle_keypress( isq , key ) ;
00623       }
00624 
00625    /*--- opened a graph viewer: maybe modify it ---*/
00626 
00627    } else if( gra != NULL ){
00628 
00629       /* geometry */
00630 
00631       if( gxx >= 0 && gyy >= 0 )
00632         XtVaSetValues( gra->fdw_graph, XmNx, gxx, XmNy, gyy, NULL ) ;
00633       if( gww > 0 && ghh > 0 )
00634         XtVaSetValues( gra->fdw_graph, XmNwidth, gww, XmNheight, ghh, NULL ) ;
00635 
00636       /* matrix */
00637 
00638       cpt = strstr(cmd,"matrix=") ;
00639       if( cpt == NULL ) cpt = strstr(cmd,"matrix:") ;
00640       if( cpt != NULL ){
00641         int mat = (int) strtod( cpt+7 , NULL ) ;
00642         if( mat > 0 )
00643           drive_MCW_grapher( gra , graDR_setmatrix , (XtPointer)mat ) ;
00644       }
00645 
00646       /* pinnum OR pintop */
00647 
00648       cpt = strstr(cmd,"pinnum=") ;
00649       if( cpt == NULL ) cpt = strstr(cmd,"pinnum:") ;
00650       if( cpt == NULL ) cpt = strstr(cmd,"pintop=") ;
00651       if( cpt == NULL ) cpt = strstr(cmd,"pintop:") ;
00652       if( cpt != NULL ){
00653         int pn = (int) strtod( cpt+7 , NULL ) ;
00654         if( pn >= MIN_PIN )
00655           drive_MCW_grapher( gra, graDR_setpinnum, (XtPointer)pn ) ;
00656       }
00657 
00658       /* pinbot [19 Mar 2004] */
00659 
00660       cpt = strstr(cmd,"pinbot=") ;
00661       if( cpt == NULL ) cpt = strstr(cmd,"pinbot:") ;
00662       if( cpt != NULL ){
00663         int pn = (int) strtod( cpt+7 , NULL ) ;
00664         if( pn > 0 )
00665           drive_MCW_grapher( gra, graDR_setpinbot, (XtPointer)pn ) ;
00666       }
00667 
00668       /* iconify [06 Aug 2002] */
00669 
00670       cpt = strstr(cmd,"iconi") ;
00671       if( cpt != NULL ){
00672         XIconifyWindow( XtDisplay(gra->fdw_graph) ,
00673                          XtWindow(gra->fdw_graph)  ,
00674                          gra->dc->screen_num   ) ;
00675       }
00676 
00677       /* keypress [18 Feb 2005] */
00678 
00679       cpt = strstr(cmd,"keypress=") ;
00680       if( cpt == NULL ) cpt = strstr(cmd,"keypress:") ;
00681       if( cpt != NULL ){
00682         char buf[2] ;
00683         cpt += 9 ;
00684         if( *cpt == '\'' || *cpt == '\"' ) cpt++ ;
00685              if( strncmp(cpt,"XK_Left" ,7) == 0 ) buf[0] = '<'  ;
00686         else if( strncmp(cpt,"XK_Right",8) == 0 ) buf[0] = '>'  ;
00687         else if( strncmp(cpt,"XK_Down" ,7) == 0 ) buf[0] = 'Z'  ;
00688         else if( strncmp(cpt,"XK_Up"   ,5) == 0 ) buf[0] = 'z'  ;
00689         else                                      buf[0] = *cpt ;
00690         if( buf[0] == 'N' ) buf[0] = '\0' ;  /* bad key for this */
00691         buf[1] = '\0' ;
00692         GRA_timer_stop( gra ) ;
00693         GRA_handle_keypress( gra , buf , NULL ) ;
00694       }
00695 
00696 
00697    /*--- opened the controller itself: maybe move it ---*/
00698 
00699    } else {
00700 
00701       /* geometry */
00702 
00703       if( gxx >= 0 && gyy >= 0 )
00704         XtVaSetValues( im3d->vwid->top_shell, XmNx, gxx, XmNy, gyy, NULL ) ;
00705 
00706       /* iconify [06 Aug 2002] */
00707 
00708       cpt = strstr(cmd,"iconi") ;
00709       if( cpt != NULL ){
00710         XIconifyWindow( XtDisplay(im3d->vwid->top_shell) ,
00711                          XtWindow(im3d->vwid->top_shell)  ,
00712                          im3d->dc->screen_num   ) ;
00713       }
00714 
00715    }
00716 
00717    /*-- finito --*/
00718 
00719    XmUpdateDisplay( im3d->vwid->top_shell ) ;
00720    RETURN(0) ;
00721 }

int AFNI_drive_pbar_rotate char *    cmd [static]
 

PBAR_ROTATE [c.]{+|-} "PBAR_ROTATE A.+" ---------------------------------------------------------------------------

Definition at line 1833 of file afni_driver.c.

References AFNI_controller_code_to_index(), AFNI_library_type::controllers, ENTRY, AFNI_widget_set::func, GLOBAL_library, IM3D_OPEN, AFNI_function_widgets::inten_pbar, RETURN, rotate_MCW_pbar(), and Three_D_View::vwid.

01834 {
01835    int ic , dadd=2 , nn ;
01836    MCW_pbar *pbar ;
01837    Three_D_View *im3d ;
01838 
01839 ENTRY("AFNI_drive_pbar_rotate") ;
01840 
01841    if( cmd == NULL || strlen(cmd) < 1 ) RETURN(-1) ;
01842 
01843    ic = AFNI_controller_code_to_index( cmd ) ;
01844    if( ic < 0 ){ ic = 0 ; dadd = 0 ; }
01845 
01846    im3d = GLOBAL_library.controllers[ic] ;
01847    if( !IM3D_OPEN(im3d) ) RETURN(-1) ;
01848 
01849    /* get sign */
01850 
01851    switch( cmd[dadd] ){
01852      default: RETURN(-1) ;
01853      case '+': nn =  1 ; break ;
01854      case '-': nn = -1 ; break ;
01855    }
01856 
01857    rotate_MCW_pbar( im3d->vwid->func->inten_pbar , nn ) ;
01858    RETURN(0) ;
01859 }

int AFNI_drive_purge_memory char *    cmd [static]
 

Purge named dataset or all datasets from memory.

Definition at line 196 of file afni_driver.c.

References AFNI_purge_dsets(), THD_slist_find::dset_index, ENTRY, FIND_IDCODE, FIND_PREFIX, GLOBAL_library, LAST_VIEW_TYPE, MCW_IDSIZE, MCW_strncpy, PURGE_DSET, RETURN, THD_slist_find::sess_index, THD_sessionlist::ssar, AFNI_library_type::sslist, MCW_idcode::str, THD_dset_in_sessionlist(), and THD_MAX_NAME.

00197 {
00198    char dname[THD_MAX_NAME] ;
00199    THD_slist_find slf ;
00200    int ic ;
00201 
00202 ENTRY("AFNI_drive_purge_memory") ;
00203 
00204    if( *cmd == '\0' ){ AFNI_purge_dsets(1); RETURN(0); }
00205 
00206    /* get dataset name, truncate trailing blanks */
00207 
00208    MCW_strncpy( dname , cmd , THD_MAX_NAME ) ;
00209    for( ic=strlen(dname)-1 ; ic >= 0 ; ic-- )
00210      if( isspace(dname[ic]) || iscntrl(dname[ic]) ) dname[ic] = '\0' ;
00211      else break ;
00212 
00213    if( strlen(dname) == 0 ) RETURN(-1) ;
00214 
00215    /* find this dataset in current session of this controller */
00216 
00217    slf = THD_dset_in_sessionlist( FIND_PREFIX, dname, GLOBAL_library.sslist,-1 );
00218 
00219    if( slf.dset_index < 0 ){   /* 18 Mar 2005 */
00220      MCW_idcode idcode ;
00221      MCW_strncpy( idcode.str , dname , MCW_IDSIZE ) ;
00222      slf = THD_dset_in_sessionlist( FIND_IDCODE, &idcode,
00223                                     GLOBAL_library.sslist,-1 );
00224    }
00225 
00226    if( slf.sess_index >= 0 && slf.dset_index >= 0 ){
00227      THD_3dim_dataset **dss =
00228        GLOBAL_library.sslist->ssar[slf.sess_index]->dsset[slf.dset_index] ;
00229      for( ic=0 ; ic <= LAST_VIEW_TYPE ; ic++ ) PURGE_DSET( dss[ic] ) ;
00230      RETURN(0) ;
00231    }
00232 
00233    RETURN(-1) ;
00234 }

int AFNI_drive_quit char *    cmd [static]
 

Definition at line 856 of file afni_driver.c.

References RWC_sleep().

00857 {
00858   int ii ;
00859   fprintf(stderr,"\n******* AFNI is commanded to quit! ") ; fflush(stderr) ;
00860   for( ii=0 ; ii < 7 ; ii++ ){ RWC_sleep(100); fprintf(stderr,"*"); fflush(stderr); }
00861   fprintf(stderr,"\n\n") ;
00862   exit(0) ;
00863 }

int AFNI_drive_rescan_controller char *    code [static]
 

Definition at line 278 of file afni_driver.c.

References AFNI_controller_code_to_index(), AFNI_rescan_CB(), AFNI_library_type::controllers, ENTRY, GLOBAL_library, IM3D_OPEN, and RETURN.

00279 {
00280    int ic ;
00281    Three_D_View *im3d ;
00282 
00283 ENTRY("AFNI_rescan_controller") ;
00284 
00285    ic = AFNI_controller_code_to_index( code ) ;
00286    if( ic < 0 ) ic = 0 ;                       /* default = A */
00287 
00288    im3d = GLOBAL_library.controllers[ic] ;
00289    if( !IM3D_OPEN(im3d) ) RETURN(-1) ;
00290 
00291    /* same callback as Rescan This */
00292 
00293    AFNI_rescan_CB( NULL , (XtPointer)im3d , NULL ) ;
00294    RETURN(0) ;
00295 }

int AFNI_drive_save_jpeg char *    cmd [static]
 

SAVE_JPEG [c.]imagewindowname fname

Definition at line 2118 of file afni_driver.c.

References AFNI_controller_code_to_index(), AFNI_library_type::controllers, drive_MCW_imseq(), ENTRY, ERROR_message(), Three_D_View::g123, Three_D_View::g231, Three_D_View::g312, GLOBAL_library, GRA_file_pixmap(), IM3D_OPEN, isq, isqDR_save_jpeg, RETURN, Three_D_View::s123, Three_D_View::s231, Three_D_View::s312, STRING_HAS_SUFFIX, AFNI_widget_set::top_shell, and Three_D_View::vwid.

02119 {
02120    int ic , dadd=2 ;
02121    Three_D_View *im3d ;
02122    char junk[256] , fname[288] ;
02123    MCW_imseq   *isq=NULL ;
02124    MCW_grapher *gra=NULL ;
02125 
02126 ENTRY("AFNI_drive_save_jpeg") ;
02127 
02128    /* make sure the controller itself is open */
02129 
02130    if( strlen(cmd) < 3 ) RETURN(-1) ;
02131 
02132    ic = AFNI_controller_code_to_index( cmd ) ;
02133    if( ic < 0 ){ ic = 0 ; dadd = 0 ; }
02134 
02135    im3d = GLOBAL_library.controllers[ic] ;
02136    if( !IM3D_OPEN(im3d) ){
02137      ERROR_message("SAVE_JPEG %s: controller not open",cmd); RETURN(-1);
02138    }
02139 
02140    /* extract the filename to save into */
02141 
02142    junk[0] = fname[0] = '\0' ;
02143    sscanf( cmd+dadd , "%255s%255s" , junk , fname ) ;
02144    if( junk[0] == '\0' || fname[0] == '\0' ){
02145      ERROR_message("SAVE_JPEG %s: something is missing",cmd); RETURN(-1);
02146      RETURN(-1) ;
02147    }
02148 
02149    if( !STRING_HAS_SUFFIX(fname,".jpg") && !STRING_HAS_SUFFIX(fname,".JPG") )
02150      strcat(fname,".jpg") ;
02151 
02152    /* find graph or image window */
02153 
02154         if( strstr(cmd+dadd,"axialimage")    != NULL ) isq = im3d->s123 ;
02155    else if( strstr(cmd+dadd,"sagittalimage") != NULL ) isq = im3d->s231 ;
02156    else if( strstr(cmd+dadd,"coronalimage")  != NULL ) isq = im3d->s312 ;
02157    else if( strstr(cmd+dadd,"axialgraph")    != NULL ) gra = im3d->g123 ;
02158    else if( strstr(cmd+dadd,"sagittalgraph") != NULL ) gra = im3d->g231 ;
02159    else if( strstr(cmd+dadd,"coronalgraph")  != NULL ) gra = im3d->g312 ;
02160 
02161    XmUpdateDisplay( im3d->vwid->top_shell ) ;
02162 
02163    if( isq != NULL ){
02164      drive_MCW_imseq( isq, isqDR_save_jpeg , (XtPointer)fname ) ;
02165    } else if( gra != NULL ){
02166      GRA_file_pixmap( gra , fname ) ;
02167    } else {
02168      ERROR_message("SAVE_JPEG %s: don't understand windowname",cmd) ;
02169      RETURN(-1) ;
02170    }
02171 
02172    RETURN(0) ;
02173 }

int AFNI_drive_set_dicom_xyz char *    cmd [static]
 

SET_DICOM_XYZ [c.] x y z

Definition at line 2206 of file afni_driver.c.

References AFNI_controller_code_to_index(), AFNI_jumpto_dicom(), AFNI_library_type::controllers, GLOBAL_library, and IM3D_OPEN.

02207 {
02208    int ic , dadd=2 ;
02209    Three_D_View *im3d ;
02210    float x,y,z ;
02211 
02212    if( strlen(cmd) < 3 ) return -1;
02213 
02214    ic = AFNI_controller_code_to_index( cmd ) ;
02215    if( ic < 0 ){ ic = 0 ; dadd = 0 ; }
02216    im3d = GLOBAL_library.controllers[ic] ;
02217    if( !IM3D_OPEN(im3d) ) return -1 ;
02218 
02219    ic = sscanf( cmd+dadd , "%f%f%f" , &x,&y,&z ) ;
02220    if( ic < 3 ) return -1 ;
02221    AFNI_jumpto_dicom( im3d , x,y,z ) ;
02222    return 0 ;
02223 }

int AFNI_drive_set_ijk char *    cmd [static]
 

SET_IJK [c.] i j k

Definition at line 2250 of file afni_driver.c.

References AFNI_controller_code_to_index(), AFNI_set_viewpoint(), AFNI_library_type::controllers, GLOBAL_library, i, IM3D_OPEN, and REDISPLAY_ALL.

02251 {
02252    int ic , dadd=2 ;
02253    Three_D_View *im3d ;
02254    int i,j,k ;
02255 
02256    if( strlen(cmd) < 3 ) return -1;
02257 
02258    ic = AFNI_controller_code_to_index( cmd ) ;
02259    if( ic < 0 ){ ic = 0 ; dadd = 0 ; }
02260    im3d = GLOBAL_library.controllers[ic] ;
02261    if( !IM3D_OPEN(im3d) ) return -1 ;
02262 
02263    ic = sscanf( cmd+dadd , "%d%d%d" , &i,&j,&k ) ;
02264    if( ic < 3 ) return -1 ;
02265    AFNI_set_viewpoint( im3d , i,j,k , REDISPLAY_ALL ) ;
02266    return 0 ;
02267 }

int AFNI_drive_set_pbar_all char *    cmd [static]
 

SET_PBAR_ALL [c.]{+|-}num val=color val=color ... "SET_PBAR_ALL A.+5 1.0=yellow 0.5=red 0.05=none -0.05=blue -0.50=cyan" "SET_PBAR_ALL A.+99 topval colorscale_name FLIP ROTA=n" ---------------------------------------------------------------------------

Definition at line 1718 of file afni_driver.c.

References AFNI_controller_code_to_index(), AFNI_hintize_pbar(), AFNI_inten_pbar_CB(), alter_MCW_pbar(), AV_assign_ival(), MCW_pbar::bigmode, MCW_pbar::bigset, AFNI_library_type::controllers, AFNI_library_type::dc, DC_find_overlay_color(), ENTRY, AFNI_view_info::fim_autorange, AFNI_view_info::fim_range, FIX_SCALE_SIZE, flip(), AFNI_widget_set::func, GLOBAL_library, HIDE_SCALE, IM3D_OPEN, AFNI_function_widgets::inten_av, AFNI_function_widgets::inten_bbox, AFNI_function_widgets::inten_pbar, MCW_set_bbox(), MCW_pbar::mode, NORMAL_cursorize, NPANE_MAX, NPANE_MIN, MCW_pbar::ov_index, MCW_pbar::ovin_save, MCW_pbar::panew, PBAR_flip(), PBAR_set_bigmap(), PBAR_set_bigmode(), PBAR_set_panecolor(), pmax, pmin, POPUP_cursorize, RETURN, rotate_MCW_pbar(), AFNI_view_info::use_posfunc, Three_D_View::vinfo, and Three_D_View::vwid.

01719 {
01720    int ic , dadd=2 , npan=0 , pos , nn , ii,jj ;
01721    float pval[NPANE_MAX+1] , val ;
01722    int   pcol[NPANE_MAX]   , col , flip=0 , rota=0 ;
01723    char  str[256] , *cpt ;
01724    MCW_pbar *pbar ;
01725    Three_D_View *im3d ;
01726 
01727 ENTRY("AFNI_drive_set_pbar_all") ;
01728 
01729    if( cmd == NULL || strlen(cmd) < 4 ) RETURN(-1) ;
01730 
01731    ic = AFNI_controller_code_to_index( cmd ) ;
01732    if( ic < 0 ){ ic = 0 ; dadd = 0 ; }
01733 
01734    im3d = GLOBAL_library.controllers[ic] ;
01735    if( !IM3D_OPEN(im3d) ) RETURN(-1) ;
01736 
01737    /* get sign */
01738 
01739    switch( cmd[dadd] ){
01740      default: RETURN(-1) ;
01741      case '+': pos = 1 ; break ;
01742      case '-': pos = 0 ; break ;
01743    }
01744    dadd++ ;
01745 
01746    /* get number of panes */
01747 
01748    sscanf( cmd+dadd , "%d%n" , &npan , &nn ) ;
01749    if( npan < NPANE_MIN ) RETURN(-1) ;
01750    if( npan > NPANE_MAX ) npan = NPANE_MAX+1 ;
01751    dadd += nn ;
01752 
01753    pbar = im3d->vwid->func->inten_pbar ;
01754 
01755    if( npan <= NPANE_MAX ){ /* discrete panes: get value=colorname array */
01756 
01757      for( ii=0 ; ii < npan ; ii++ ){
01758        str[0] = '\0' ; nn = 0 ;
01759        sscanf( cmd+dadd , "%f=%255s%n" , &val,str,&nn ) ;
01760        if( str[0] == '\0' || nn == 0 ) RETURN(-1) ;  /* can't parse */
01761 
01762        col = DC_find_overlay_color( GLOBAL_library.dc , str ) ;
01763        if( col < 0 )                   RETURN(-1) ;  /* bad color name */
01764 
01765        for( jj=0 ; jj < ii ; jj++ )                  /* check ordering */
01766          if( pval[jj] <= val )         RETURN(-1) ;
01767 
01768        if( ii > 0 ){                                 /* check size */
01769          if( fabs(val) >= pval[0] )    RETURN(-1) ;
01770          if( pos && val <= 0.0 )       RETURN(-1) ;
01771        } else {
01772          if( val <= 0.0 )              RETURN(-1) ;
01773        }
01774 
01775        pval[ii] = val ; pcol[ii] = col ;
01776        dadd += nn ;
01777      }
01778      if( pos ) pval[npan] = 0.0 ;        /* set bottom level */
01779      else      pval[npan] = -pval[0] ;
01780 
01781    } else {     /* 03 Feb 2003: get topval and colorscale_name */
01782 
01783      str[0] = '\0' ; val = 0.0 ;
01784      sscanf( cmd+dadd , "%f %s" , &val, str ) ;
01785      if( val <= 0.0 ) RETURN(-1) ;
01786 
01787      flip = ( strstr(cmd+dadd,"FLIP") != NULL ) ;
01788 
01789      cpt = strstr(cmd+dadd,"ROTA=") ;
01790      if( cpt == NULL ) cpt = strstr(cmd+dadd,"ROTA:") ;
01791      if( cpt != NULL ) sscanf(cpt+5,"%d",&rota) ;
01792    }
01793 
01794    /* now set pbar values (and other widgets) */
01795 
01796    im3d->vinfo->use_posfunc = pbar->mode = pos ;
01797    MCW_set_bbox( im3d->vwid->func->inten_bbox , pos ) ;
01798    AV_assign_ival( im3d->vwid->func->inten_av , npan ) ;
01799 
01800    HIDE_SCALE(im3d) ;
01801    if( npan <= NPANE_MAX ){         /* set discrete panels */
01802      for( ii=0 ; ii < npan ; ii++ ){
01803        pbar->ov_index[ii] = pbar->ovin_save[npan][ii][pos] = pcol[ii] ;
01804        PBAR_set_panecolor( pbar , ii , pcol[ii] ) ;
01805      }
01806      pbar->bigmode = 0 ;
01807      alter_MCW_pbar( pbar , npan , pval ) ;
01808      AFNI_hintize_pbar( pbar , (im3d->vinfo->fim_range != 0.0)
01809                                 ? im3d->vinfo->fim_range
01810                                 : im3d->vinfo->fim_autorange ) ;
01811      NORMAL_cursorize( pbar->panew ) ;  /* 08 Apr 2005 */
01812    } else {    /* set the colorscale */
01813      float pmax, pmin ;
01814      pbar->bigset = 0 ;
01815      pmax = val ; pmin = (pbar->mode) ? 0.0 : -pmax ;
01816      PBAR_set_bigmode( pbar , 1 , pmin,pmax ) ;
01817      PBAR_set_bigmap( pbar , str ) ;
01818      rotate_MCW_pbar( pbar , rota ) ;  /* 07 Feb 2004 */
01819      if( flip ) PBAR_flip( pbar ) ;    /* 07 Feb 2004 */
01820      AFNI_inten_pbar_CB( pbar , im3d , 0 ) ;
01821      POPUP_cursorize( pbar->panew ) ;  /* 08 Apr 2005 */
01822    }
01823    FIX_SCALE_SIZE(im3d) ;
01824 
01825    RETURN(0) ;
01826 }

int AFNI_drive_set_pbar_number char *    cmd [static]
 

SET_PBAR_NUMBER [c.]num as in "SET_PBAR_NUMBER A.3" use a large number (99, say) to turn on colorscale mode --------------------------------------------------------------------------

Definition at line 1631 of file afni_driver.c.

References AFNI_controller_code_to_index(), AFNI_inten_pbar_CB(), alter_MCW_pbar(), AV_assign_ival(), MCW_pbar::bigmode, AFNI_library_type::controllers, ENTRY, FIX_SCALE_SIZE, AFNI_widget_set::func, GLOBAL_library, HIDE_SCALE, IM3D_OPEN, AFNI_function_widgets::inten_av, AFNI_function_widgets::inten_pbar, MCW_pbar::mode, NORMAL_cursorize, NPANE_MAX, NPANE_MIN, MCW_pbar::num_panes, MCW_pbar::panew, PBAR_set_bigmode(), pmax, pmin, POPUP_cursorize, MCW_pbar::pval_save, RETURN, strtod(), and Three_D_View::vwid.

01632 {
01633    int ic , dadd=2 , num=-1 ;
01634    Three_D_View *im3d ;
01635    MCW_pbar *pbar ;
01636 
01637 ENTRY("AFNI_drive_set_pbar_number") ;
01638 
01639    if( cmd == NULL || strlen(cmd) < 1 ) RETURN(-1) ;
01640 
01641    ic = AFNI_controller_code_to_index( cmd ) ;
01642    if( ic < 0 ){ ic = 0 ; dadd = 0 ; }
01643    if( !isdigit(cmd[dadd]) ) RETURN(-1) ;
01644 
01645    im3d = GLOBAL_library.controllers[ic] ;
01646    if( !IM3D_OPEN(im3d) ) RETURN(-1) ;
01647 
01648    pbar = im3d->vwid->func->inten_pbar ;
01649 
01650    num = (int) strtod( cmd+dadd , NULL ) ;
01651    if( num < NPANE_MIN ) RETURN(-1) ;
01652    if( num > NPANE_MAX ) num = NPANE_MAX+1 ;
01653    AV_assign_ival( im3d->vwid->func->inten_av , num ) ;
01654 
01655    HIDE_SCALE(im3d) ;
01656    if( num <= NPANE_MAX ){
01657      pbar->bigmode = 0 ;
01658      alter_MCW_pbar( pbar , num , NULL ) ;
01659      NORMAL_cursorize( pbar->panew ) ;  /* 08 Apr 2005 */
01660    } else {
01661      int npane=pbar->num_panes , jm=pbar->mode ;
01662      float pmax=pbar->pval_save[npane][0][jm] ,
01663            pmin=pbar->pval_save[npane][npane][jm] ;
01664      PBAR_set_bigmode( pbar , 1 , pmin,pmax ) ;
01665      AFNI_inten_pbar_CB( pbar , im3d , 0 ) ;
01666      POPUP_cursorize( pbar->panew ) ;  /* 08 Apr 2005 */
01667    }
01668    FIX_SCALE_SIZE(im3d) ;
01669 
01670    RETURN(0) ;
01671 }

int AFNI_drive_set_pbar_sign char *    cmd [static]
 

SET_PBAR_SIGN [c.]+ OR [c.]- as in "SET_PBAR_SIGN A.+" --------------------------------------------------------------------------

Definition at line 1678 of file afni_driver.c.

References AFNI_controller_code_to_index(), AFNI_inten_bbox_CB(), AFNI_library_type::controllers, ENTRY, AFNI_widget_set::func, GLOBAL_library, IM3D_OPEN, AFNI_function_widgets::inten_bbox, MCW_set_bbox(), PBAR_MODEBUT, RETURN, Three_D_View::vwid, and MCW_bbox::wbut.

01679 {
01680    int ic , dadd=2 , val ;
01681    Three_D_View *im3d ;
01682 
01683 ENTRY("AFNI_drive_set_pbar_sign") ;
01684 
01685    if( cmd == NULL || strlen(cmd) < 1 ) RETURN(-1) ;
01686 
01687    ic = AFNI_controller_code_to_index( cmd ) ;
01688    if( ic < 0 ){ ic = 0 ; dadd = 0 ; }
01689 
01690    im3d = GLOBAL_library.controllers[ic] ;
01691    if( !IM3D_OPEN(im3d) ) RETURN(-1) ;
01692 
01693    switch( cmd[dadd] ){
01694      default: RETURN(-1) ;
01695 
01696      case 'p':
01697      case 'P':
01698      case '+': val = 1 ; break ;
01699 
01700      case 's':
01701      case 'S':
01702      case '-': val = 0 ; break ;
01703    }
01704 
01705    MCW_set_bbox( im3d->vwid->func->inten_bbox , val ) ;
01706 
01707    AFNI_inten_bbox_CB( im3d->vwid->func->inten_bbox->wbut[PBAR_MODEBUT] ,
01708                        (XtPointer)im3d , NULL ) ;
01709    RETURN(0) ;
01710 }

int AFNI_drive_set_spm_xyz char *    cmd [static]
 

SET_SPM_XYZ [c.] x y z

Definition at line 2228 of file afni_driver.c.

References AFNI_controller_code_to_index(), AFNI_jumpto_dicom(), AFNI_library_type::controllers, GLOBAL_library, and IM3D_OPEN.

02229 {
02230    int ic , dadd=2 ;
02231    Three_D_View *im3d ;
02232    float x,y,z ;
02233 
02234    if( strlen(cmd) < 3 ) return -1;
02235 
02236    ic = AFNI_controller_code_to_index( cmd ) ;
02237    if( ic < 0 ){ ic = 0 ; dadd = 0 ; }
02238    im3d = GLOBAL_library.controllers[ic] ;
02239    if( !IM3D_OPEN(im3d) ) return -1 ;
02240 
02241    ic = sscanf( cmd+dadd , "%f%f%f" , &x,&y,&z ) ;
02242    if( ic < 3 ) return -1 ;
02243    AFNI_jumpto_dicom( im3d , -x,-y,z ) ;
02244    return 0 ;
02245 }

int AFNI_drive_set_threshnew char *    cmd [static]
 

SET_THRESHNEW [c].val [**] -- 06 Feb 2004 as in "SET_THRESHNEW A.0.372" or "SET_THRESHNEW 0.372 **" (the "**" means to set the range too) --------------------------------------------------------------------------

Definition at line 1554 of file afni_driver.c.

References AFNI_controller_code_to_index(), AFNI_set_thresh_top(), AFNI_thr_scale_CB(), AFNI_library_type::controllers, DSET_BRICK_STATAUX, DSET_BRICK_STATCODE, ENTRY, Three_D_View::fim_now, AFNI_widget_set::func, AFNI_view_info::func_thresh_top, GLOBAL_library, IM3D_OPEN, RETURN, strtod(), THD_pval_to_stat(), THR_FACTOR, AFNI_view_info::thr_index, AFNI_function_widgets::thr_scale, THR_TOP_EXPON, THR_TOP_VALUE, Three_D_View::vinfo, and Three_D_View::vwid.

01555 {
01556    int ic,dadd , olddec,newdec , ival,smax,id,stop , dopval,dostar;
01557    Three_D_View *im3d ;
01558    float val , pval ;
01559    char *cpt ;
01560    static float tval[9] = { 1.0 , 10.0 , 100.0 , 1000.0 , 10000.0 ,
01561                             100000.0 , 1000000.0 , 10000000.0 , 100000000.0 } ;
01562 
01563 ENTRY("AFNI_drive_set_threshnew") ;
01564 
01565    if( cmd == NULL || *cmd == '\0' ) RETURN(-1) ;
01566 
01567    ic = AFNI_controller_code_to_index( cmd ) ;
01568    if( ic < 0 ){
01569      ic = 0 ; dadd = 0 ;
01570    } else {
01571      if( cmd[1] == '\0' ) RETURN(-1) ;   /* no value following? */
01572      dadd = 2 ;                          /* skip period following controller */
01573    }
01574 
01575    im3d = GLOBAL_library.controllers[ic] ;
01576    if( !IM3D_OPEN(im3d) ) RETURN(-1) ;   /* stupid user */
01577 
01578    /* get val from command line */
01579 
01580    val = strtod( cmd+dadd , &cpt ) ;
01581    if( val < 0.0 || val > THR_TOP_VALUE ) RETURN(-1) ; /* stupid user */
01582 
01583    /* get current scale decimal setting */
01584 
01585    olddec = (int)rint( log10(im3d->vinfo->func_thresh_top) ) ;
01586         if( olddec < 0             ) olddec = 0 ;
01587    else if( olddec > THR_TOP_EXPON ) olddec = THR_TOP_EXPON ;
01588    newdec = olddec ;
01589 
01590    smax  = (int)rint( pow(10.0,THR_TOP_EXPON) ) ;
01591    stop  = smax - 1 ;                             /* max slider value */
01592 
01593    dopval = (val >= 0.0) && (val <= 1.0) && (strchr(cpt,'p') != NULL) &&
01594             (DSET_BRICK_STATCODE(im3d->fim_now,im3d->vinfo->thr_index) > 0) ;
01595 
01596    dostar = (val > 0.0) && (strchr(cpt,'*') != NULL) ;
01597 
01598    if( dopval ){
01599      pval = THD_pval_to_stat( val ,
01600               DSET_BRICK_STATCODE(im3d->fim_now,im3d->vinfo->thr_index) ,
01601               DSET_BRICK_STATAUX (im3d->fim_now,im3d->vinfo->thr_index)  ) ;
01602      if( pval >= 0.0 ) val = pval ;
01603    }
01604 
01605    if( val >= im3d->vinfo->func_thresh_top || dostar ){ /* reset scale range */
01606 
01607      newdec = (int)( log10(val) + 1.0 ) ;
01608           if( newdec < 0             ) newdec = 0 ;
01609      else if( newdec > THR_TOP_EXPON ) newdec = THR_TOP_EXPON ;
01610    }
01611 
01612    if( newdec != olddec )
01613      AFNI_set_thresh_top( im3d , tval[newdec] ) ;
01614 
01615    ival = rint( val/(THR_FACTOR*tval[newdec]) ) ;
01616         if( ival < 0    ) ival = 0    ;
01617    else if( ival > stop ) ival = stop ;
01618 
01619    XmScaleSetValue( im3d->vwid->func->thr_scale , ival ) ;
01620 
01621    AFNI_thr_scale_CB( im3d->vwid->func->thr_scale, (XtPointer)im3d, NULL ) ;
01622    RETURN(0) ;
01623 }

int AFNI_drive_set_threshold char *    cmd [static]
 

SET_THRESHOLD [c].val [dec] -- 16 Jan 2003 as in "SET_THRESHOLD A.3327 2" or "SET_THRESHOLD .9932 2" --------------------------------------------------------------------------

Definition at line 1509 of file afni_driver.c.

References AFNI_controller_code_to_index(), AFNI_set_thresh_top(), AFNI_thr_scale_CB(), AFNI_library_type::controllers, ENTRY, AFNI_widget_set::func, GLOBAL_library, IM3D_OPEN, RETURN, strtod(), THR_FACTOR, AFNI_function_widgets::thr_scale, THR_TOP_EXPON, and Three_D_View::vwid.

01510 {
01511    int ic , dadd=1 , dec=-1 , ival , smax ;
01512    Three_D_View *im3d ;
01513    float val ;
01514    char *cpt ;
01515    static float tval[9] = { 1.0 , 10.0 , 100.0 , 1000.0 , 10000.0 ,
01516                             100000.0 , 1000000.0 , 10000000.0 , 100000000.0 } ;
01517 
01518 ENTRY("AFNI_drive_set_threshold") ;
01519 
01520    if( cmd == NULL || strlen(cmd) < 3 ) RETURN(-1) ;
01521 
01522    ic = AFNI_controller_code_to_index( cmd ) ;
01523    if( ic < 0 ){ ic = 0 ; dadd = 0 ; }
01524 
01525    im3d = GLOBAL_library.controllers[ic] ;
01526    if( !IM3D_OPEN(im3d) ) RETURN(-1) ;
01527 
01528    /* get val and set scale */
01529 
01530    if( cmd[dadd] != '.' ) RETURN(-1) ;
01531    val = strtod( cmd+dadd , &cpt ) ;
01532    ival = rint(val/THR_FACTOR) ;
01533    smax = (int)( pow(10.0,THR_TOP_EXPON) + 0.001 ) - 1 ;
01534    if( ival < 0 || ival > smax ) RETURN(-1) ;
01535    XmScaleSetValue( im3d->vwid->func->thr_scale , ival ) ;
01536 
01537    /* get dec, if present, and apply it */
01538 
01539    sscanf(cpt,"%d",&dec) ;
01540 
01541    if( dec >= 0 && dec <= THR_TOP_EXPON )
01542      AFNI_set_thresh_top( im3d , tval[dec] ) ;
01543 
01544    AFNI_thr_scale_CB( im3d->vwid->func->thr_scale, (XtPointer)im3d, NULL ) ;
01545    RETURN(0) ;
01546 }

int AFNI_drive_set_view char *    cmd [static]
 

SET_VIEW [c.]viewname

Definition at line 2178 of file afni_driver.c.

References AFNI_controller_code_to_index(), AFNI_switchview_CB(), AFNI_library_type::controllers, GLOBAL_library, IM3D_OPEN, MCW_set_bbox(), AFNI_widget_set::view, VIEW_ACPCALIGNED_TYPE, AFNI_viewing_widgets::view_bbox, VIEW_ORIGINAL_TYPE, VIEW_TALAIRACH_TYPE, AFNI_view_info::view_type, Three_D_View::vinfo, Three_D_View::vwid, and MCW_bbox::wbut.

02179 {
02180    int ic , vv=-1 ;
02181    Three_D_View *im3d ;
02182 
02183    if( strlen(cmd) < 3 ) return -1;
02184 
02185    ic = AFNI_controller_code_to_index( cmd ) ;
02186    if( ic < 0 ) ic = 0 ;
02187    im3d = GLOBAL_library.controllers[ic] ;
02188    if( !IM3D_OPEN(im3d) ) return -1 ;
02189 
02190         if( strstr(cmd,"orig") != NULL ) vv = VIEW_ORIGINAL_TYPE ;
02191    else if( strstr(cmd,"acpc") != NULL ) vv = VIEW_ACPCALIGNED_TYPE ;
02192    else if( strstr(cmd,"tlrc") != NULL ) vv = VIEW_TALAIRACH_TYPE ;
02193    else                                  return -1 ;
02194 
02195    if( vv == im3d->vinfo->view_type ) return 0 ;  /* nothing to do */
02196    if( !XtIsSensitive(im3d->vwid->view->view_bbox->wbut[vv]) ) return -1 ;
02197 
02198    MCW_set_bbox( im3d->vwid->view->view_bbox , 1 << vv ) ;
02199    AFNI_switchview_CB( NULL , (XtPointer)im3d , NULL ) ;
02200    return 0 ;
02201 }

int AFNI_drive_set_xhairs char *    cmd [static]
 

SET_XHAIRS [c.]code

Definition at line 2272 of file afni_driver.c.

References AFNI_controller_code_to_index(), AFNI_crosshair_visible_CB(), AV_assign_ival(), AFNI_library_type::controllers, AFNI_imaging_widgets::crosshair_av, GLOBAL_library, i, IM3D_OPEN, AFNI_widget_set::imag, and Three_D_View::vwid.

02273 {
02274    int ic , dadd=2 , hh=-1 ;
02275    Three_D_View *im3d ;
02276    int i,j,k ;
02277 
02278    if( strlen(cmd) < 3 ) return -1;
02279 
02280    ic = AFNI_controller_code_to_index( cmd ) ;
02281    if( ic < 0 ){ ic = 0 ; dadd = 0 ; }
02282    im3d = GLOBAL_library.controllers[ic] ;
02283    if( !IM3D_OPEN(im3d) ) return -1 ;
02284 
02285         if( strstr(cmd,"OFF")    != NULL ) hh = 0 ;
02286    else if( strstr(cmd,"SINGLE") != NULL ) hh = 1 ;
02287    else if( strstr(cmd,"MULTI")  != NULL ) hh = 2 ;
02288    else if( strstr(cmd,"LR_AP")  != NULL ) hh = 3 ;
02289    else if( strstr(cmd,"LR_IS")  != NULL ) hh = 4 ;
02290    else if( strstr(cmd,"AP_IS")  != NULL ) hh = 5 ;
02291    else if( strstr(cmd,"LR")     != NULL ) hh = 6 ;
02292    else if( strstr(cmd,"AP")     != NULL ) hh = 7 ;
02293    else if( strstr(cmd,"IS")     != NULL ) hh = 8 ;
02294    else                                    return -1 ;
02295 
02296    AV_assign_ival( im3d->vwid->imag->crosshair_av, hh ) ;
02297    AFNI_crosshair_visible_CB( im3d->vwid->imag->crosshair_av, (XtPointer)im3d );
02298    return 0 ;
02299 }

int AFNI_drive_switch_anatomy char *    cmd [static]
 

Definition at line 351 of file afni_driver.c.

References AFNI_controller_code_to_index(), AFNI_finalize_dataset_CB(), AFNI_viewing_widgets::choose_anat_pb, AFNI_library_type::controllers, THD_slist_find::dset_index, ENTRY, FIND_IDCODE, FIND_PREFIX, GLOBAL_library, IM3D_OPEN, MCW_choose_cbs::ival, MCW_IDSIZE, MCW_strncpy, RETURN, Three_D_View::ss_now, MCW_idcode::str, THD_dset_in_session(), THD_MAX_NAME, AFNI_widget_set::view, and Three_D_View::vwid.

00352 {
00353    int ic , dadd=2 ;
00354    Three_D_View *im3d ;
00355    char dname[THD_MAX_NAME] ;
00356    MCW_choose_cbs cbs ;
00357    THD_slist_find slf ;
00358 
00359 ENTRY("AFNI_switch_anatomy") ;
00360 
00361    if( cmd == NULL || strlen(cmd) < 3 ) RETURN(-1) ;
00362 
00363    ic = AFNI_controller_code_to_index( cmd ) ;
00364    if( ic < 0 ){ ic = 0 ; dadd = 0 ; }
00365 
00366    im3d = GLOBAL_library.controllers[ic] ;
00367    if( !IM3D_OPEN(im3d) ) RETURN(-1) ;
00368 
00369    /* get dataset name, truncate trailing blanks */
00370 
00371    MCW_strncpy( dname , cmd+dadd , THD_MAX_NAME ) ;
00372    for( ic=strlen(dname)-1 ; ic >= 0 ; ic-- )
00373      if( isspace(dname[ic]) || iscntrl(dname[ic]) ) dname[ic] = '\0' ;
00374      else break ;
00375 
00376    if( strlen(dname) == 0 ) RETURN(-1) ;
00377 
00378    /* find this dataset in current session of this controller */
00379 
00380    slf = THD_dset_in_session( FIND_PREFIX , dname , im3d->ss_now ) ;
00381 
00382    if( slf.dset_index < 0 ){   /* 18 Mar 2005 */
00383      MCW_idcode idcode ;
00384      MCW_strncpy( idcode.str , dname , MCW_IDSIZE ) ;
00385      slf = THD_dset_in_session( FIND_IDCODE , &idcode , im3d->ss_now ) ;
00386    }
00387 
00388    if( slf.dset_index < 0 ) RETURN(-1) ;
00389 
00390    cbs.ival = slf.dset_index ;
00391 
00392    /* same callback as Switch Anatomy */
00393 
00394    AFNI_finalize_dataset_CB( im3d->vwid->view->choose_anat_pb ,
00395                              (XtPointer)im3d ,  &cbs          ) ;
00396 
00397    RETURN(0) ;
00398 }

int AFNI_drive_switch_function char *    cmd [static]
 

Definition at line 405 of file afni_driver.c.

References AFNI_controller_code_to_index(), AFNI_finalize_dataset_CB(), AFNI_viewing_widgets::choose_func_pb, AFNI_library_type::controllers, THD_slist_find::dset_index, ENTRY, FIND_IDCODE, FIND_PREFIX, GLOBAL_library, IM3D_OPEN, MCW_choose_cbs::ival, MCW_IDSIZE, MCW_strncpy, RETURN, Three_D_View::ss_now, MCW_idcode::str, THD_dset_in_session(), THD_MAX_NAME, AFNI_widget_set::view, and Three_D_View::vwid.

00406 {
00407    int ic , dadd=2 ;
00408    Three_D_View *im3d ;
00409    char dname[THD_MAX_NAME] ;
00410    MCW_choose_cbs cbs ;
00411    THD_slist_find slf ;
00412 
00413 ENTRY("AFNI_switch_function") ;
00414 
00415    if( cmd == NULL || strlen(cmd) < 3 ) RETURN(-1) ;
00416 
00417    ic = AFNI_controller_code_to_index( cmd ) ;
00418    if( ic < 0 ){ ic = 0 ; dadd = 0 ; }
00419 
00420    im3d = GLOBAL_library.controllers[ic] ;
00421    if( !IM3D_OPEN(im3d) ) RETURN(-1) ;
00422 
00423    /* get dataset name, truncate trailing blanks */
00424 
00425    MCW_strncpy( dname , cmd+dadd , THD_MAX_NAME ) ;
00426    for( ic=strlen(dname)-1 ; ic >= 0 ; ic-- )
00427       if( isspace(dname[ic]) || iscntrl(dname[ic]) ) dname[ic] = '\0' ;
00428       else break ;
00429 
00430    if( strlen(dname) == 0 ) RETURN(-1) ;
00431 
00432    /* find this dataset in current session of this controller */
00433 
00434    slf = THD_dset_in_session( FIND_PREFIX , dname , im3d->ss_now ) ;
00435 
00436    if( slf.dset_index < 0 ){   /* 18 Mar 2005 */
00437      MCW_idcode idcode ;
00438      MCW_strncpy( idcode.str , dname , MCW_IDSIZE ) ;
00439      slf = THD_dset_in_session( FIND_IDCODE , &idcode , im3d->ss_now ) ;
00440    }
00441 
00442    if( slf.dset_index < 0 ) RETURN(-1) ;
00443 
00444    cbs.ival = slf.dset_index ;
00445 
00446    /* same callback as Switch Function */
00447 
00448    AFNI_finalize_dataset_CB( im3d->vwid->view->choose_func_pb ,
00449                              (XtPointer)im3d ,  &cbs          ) ;
00450 
00451    RETURN(0) ;
00452 }

int AFNI_drive_switch_session char *    cmd [static]
 

Definition at line 303 of file afni_driver.c.

References AFNI_controller_code_to_index(), AFNI_finalize_dataset_CB(), AFNI_viewing_widgets::choose_sess_pb, AFNI_library_type::controllers, ENTRY, GLOBAL_library, IM3D_OPEN, MCW_choose_cbs::ival, MCW_strncpy, THD_sessionlist::num_sess, RETURN, THD_session::sessname, THD_sessionlist::ssar, AFNI_library_type::sslist, THD_MAX_NAME, AFNI_widget_set::view, and Three_D_View::vwid.

00304 {
00305    int ic , dadd=2 ;
00306    Three_D_View *im3d ;
00307    char dname[THD_MAX_NAME] ;
00308    MCW_choose_cbs cbs ;
00309 
00310 ENTRY("AFNI_switch_session") ;
00311 
00312    if( cmd == NULL || strlen(cmd) < 3 ) RETURN(-1) ;
00313 
00314    ic = AFNI_controller_code_to_index( cmd ) ;
00315    if( ic < 0 ){ ic = 0 ; dadd = 0 ; }
00316 
00317    im3d = GLOBAL_library.controllers[ic] ;
00318    if( !IM3D_OPEN(im3d) ) RETURN(-1) ;
00319 
00320    /* get session name, truncate trailing blanks */
00321 
00322    MCW_strncpy( dname , cmd+dadd , THD_MAX_NAME ) ;
00323    for( ic=strlen(dname)-1 ; ic >= 0 ; ic-- )
00324       if( isspace(dname[ic]) || iscntrl(dname[ic]) ) dname[ic] = '\0' ;
00325       else break ;
00326 
00327    if( strlen(dname) == 0 ) RETURN(-1) ;
00328 
00329    /* find session name in list of sessions (sloppy compare) */
00330 
00331    for( ic=0 ; ic < GLOBAL_library.sslist->num_sess ; ic++ )
00332       if( strstr(GLOBAL_library.sslist->ssar[ic]->sessname,dname) != NULL ) break;
00333 
00334    if( ic == GLOBAL_library.sslist->num_sess ) RETURN(-1) ;
00335 
00336    /* do the switcheroo: same callback as Switch Session */
00337 
00338    cbs.ival = ic ;
00339 
00340    AFNI_finalize_dataset_CB( im3d->vwid->view->choose_sess_pb ,
00341                              (XtPointer)im3d ,  &cbs          ) ;
00342 
00343    RETURN(0) ;
00344 }

int AFNI_drive_system char *    cmd [static]
 

Run a system() command.

Definition at line 239 of file afni_driver.c.

00240 {
00241    return system( cmd ) ;
00242 }

int AFNI_driver char *    cmdd
 

Definition at line 147 of file afni_driver.c.

References ENTRY, free, AFNI_driver_pair::fun, AFNI_driver_pair::nam, and RETURN.

Referenced by AFNI_equate_pbars(), AFNI_imag_pop_CB(), AFNI_niml_driver(), AFNI_niml_workproc(), AFNI_process_plugout(), AFNI_range_lock_carryout(), AFNI_startup_script_CB(), AFNI_startup_timeout_CB(), AFNI_thresh_lock_carryout(), and RT_process_info().

00148 {
00149    int clen , rval , ii , dd , dlen ;
00150    char *cmd , *dmd ;
00151 
00152 ENTRY("AFNI_driver") ;
00153 
00154    if( cmdd == NULL || *cmdd == '\0' ) RETURN(-1) ;  /* bad */
00155 
00156    dmd = cmd = strdup(cmdd) ; clen = strlen(cmd) ;
00157 
00158    /* skip leading blanks */
00159 
00160    for( ii=0 ; ii < clen ; ii++ )
00161       if( !isspace(cmd[ii]) ) break ;
00162 
00163    if( ii == clen ){ free(dmd); RETURN(-1); }  /* all blanks? */
00164 
00165    cmd += ii ; clen = strlen(cmd) ;
00166 
00167    /* 19 Dec 2002: trim trailing blanks */
00168 
00169    for( ii=clen-1 ; ii > 0 && isspace(cmd[ii]) ; ii-- )
00170      cmd[ii] = '\0' ;
00171 
00172    clen = strlen(cmd) ;
00173 
00174    /* scan dpair list for command */
00175 
00176    for( dd=0 ; dpair[dd].nam != NULL ; dd++ ){
00177 
00178       dlen = strlen(dpair[dd].nam) ;
00179       if( clen >= dlen                         &&
00180           strncmp(cmd,dpair[dd].nam,dlen) == 0   ){  /* found it */
00181 
00182          for( ii=dlen ; ii < clen ; ii++ )      /* skip blanks */
00183             if( !isspace(cmd[ii]) ) break ;     /* after command name */
00184 
00185          rval = dpair[dd].fun( cmd+ii ) ;       /* execute command */
00186          free(dmd) ; RETURN(rval) ;
00187       }
00188    }
00189 
00190    free(dmd) ; RETURN(-1) ;  /* not in the list */
00191 }

int AFNI_open_panel char *    cmd [static]
 

OPEN_PANEL [c.]Define_Function, etc.

Definition at line 2083 of file afni_driver.c.

References AFNI_controller_code_to_index(), AFNI_define_CB(), AFNI_library_type::controllers, AFNI_viewing_widgets::define_dmode_pb, AFNI_viewing_widgets::define_func_pb, AFNI_viewing_widgets::define_marks_pb, AFNI_widget_set::dmode, ENTRY, AFNI_marks_widgets::frame, AFNI_datamode_widgets::frame, AFNI_function_widgets::frame, AFNI_widget_set::func, GLOBAL_library, IM3D_OPEN, AFNI_widget_set::marks, RETURN, AFNI_widget_set::view, and Three_D_View::vwid.

02084 {
02085    int ic , dadd=2 , fr=-1 , tr=-1 ;
02086    Three_D_View *im3d ;
02087 
02088 ENTRY("AFNI_open_panel") ;
02089 
02090    if( cmd == NULL || strlen(cmd) < 2 ) RETURN(-1) ;
02091 
02092    ic = AFNI_controller_code_to_index( cmd ) ;
02093    if( ic < 0 ){ ic = 0 ; dadd = 0 ; }
02094 
02095    im3d = GLOBAL_library.controllers[ic] ;
02096    if( !IM3D_OPEN(im3d) ) RETURN(-1) ;
02097 
02098    /* do the right thing (simulate a button press) */
02099 
02100    if( strcmp(cmd+dadd,"Define_Function") == 0 || strcmp(cmd+dadd,"Define_Overlay") == 0 ){
02101      if( !XtIsManaged(im3d->vwid->func->frame) )
02102        AFNI_define_CB( im3d->vwid->view->define_func_pb, im3d, NULL ) ;
02103    } else if( strcmp(cmd+dadd,"Define_Datamode") == 0 ){
02104      if( !XtIsManaged(im3d->vwid->dmode->frame) )
02105        AFNI_define_CB( im3d->vwid->view->define_dmode_pb, im3d, NULL ) ;
02106    } else if( strcmp(cmd+dadd,"Define_Markers")  == 0 ){
02107      if( !XtIsManaged(im3d->vwid->marks->frame) )
02108        AFNI_define_CB( im3d->vwid->view->define_marks_pb, im3d, NULL ) ;
02109    } else {
02110      RETURN(-1) ;
02111    }
02112    RETURN(0) ;
02113 }

int AFNI_redisplay char *    cmd [static]
 

REDISPLAY

Definition at line 2059 of file afni_driver.c.

References AFNI_set_viewpoint(), AFNI_library_type::controllers, GLOBAL_library, IM3D_OPEN, MAX_CONTROLLERS, and REDISPLAY_OVERLAY.

02060 {
02061    int cc ;
02062    Three_D_View *qq3d ;
02063 
02064    for( cc=0 ; cc < MAX_CONTROLLERS ; cc++ ){
02065       qq3d = GLOBAL_library.controllers[cc] ;
02066       if( ! IM3D_OPEN(qq3d) ) continue ;
02067       AFNI_set_viewpoint( qq3d , -1,-1,-1 , REDISPLAY_OVERLAY ) ;
02068    }
02069    return(0) ;
02070 }

int AFNI_set_func_autorange char *    cmd [static]
 

SET_FUNC_AUTORANGE [c.]{+|-} "SET_FUNC_AUTORANGE A.+" ---------------------------------------------------------------------------

Definition at line 1866 of file afni_driver.c.

References AFNI_controller_code_to_index(), AFNI_range_bbox_CB(), AFNI_library_type::controllers, ENTRY, AFNI_widget_set::func, GLOBAL_library, IM3D_OPEN, MCW_set_bbox(), RANGE_AUTOBUT, AFNI_function_widgets::range_bbox, RETURN, Three_D_View::vwid, and MCW_bbox::wbut.

Referenced by AFNI_set_func_range().

01867 {
01868    int ic , dadd=2 , nn ;
01869    Three_D_View *im3d ;
01870 
01871 ENTRY("AFNI_set_func_autorange") ;
01872 
01873    if( cmd == NULL || strlen(cmd) < 1 ) RETURN(-1) ;
01874 
01875    ic = AFNI_controller_code_to_index( cmd ) ;
01876    if( ic < 0 ){ ic = 0 ; dadd = 0 ; }
01877 
01878    im3d = GLOBAL_library.controllers[ic] ;
01879    if( !IM3D_OPEN(im3d) ) RETURN(-1) ;
01880 
01881    switch( cmd[dadd] ){
01882      default: RETURN(-1) ;
01883      case '+': nn = 1 ; break ;
01884      case '-': nn = 0 ; break ;
01885    }
01886 
01887    MCW_set_bbox( im3d->vwid->func->range_bbox , nn ) ;
01888    AFNI_range_bbox_CB( im3d->vwid->func->range_bbox->wbut[RANGE_AUTOBUT] ,
01889                        im3d , NULL ) ;
01890    RETURN(0) ;
01891 }

int AFNI_set_func_range char *    cmd [static]
 

SET_FUNC_RANGE [c.]value "SET_FUNC_RANGE A.0.3333" ---------------------------------------------------------------------------

Definition at line 1898 of file afni_driver.c.

References AFNI_controller_code_to_index(), AFNI_range_av_CB(), AFNI_set_func_autorange(), AV_assign_fval(), AV_SENSITIZE, AFNI_library_type::controllers, ENTRY, AFNI_widget_set::func, GLOBAL_library, IM3D_OPEN, MCW_set_bbox(), AFNI_function_widgets::range_av, AFNI_function_widgets::range_bbox, RETURN, strtod(), AFNI_view_info::use_autorange, Three_D_View::vinfo, and Three_D_View::vwid.

01899 {
01900    int ic , dadd=2 ;
01901    Three_D_View *im3d ;
01902    float val ;
01903 
01904 ENTRY("AFNI_set_func_range") ;
01905 
01906    if( cmd == NULL || strlen(cmd) < 1 ) RETURN(-1) ;
01907 
01908    ic = AFNI_controller_code_to_index( cmd ) ;
01909    if( ic < 0 ){ ic = 0 ; dadd = 0 ; }
01910 
01911    im3d = GLOBAL_library.controllers[ic] ;
01912    if( !IM3D_OPEN(im3d) ) RETURN(-1) ;
01913 
01914    val = strtod( cmd+dadd , NULL ) ;
01915    if( val <  0.0 ) RETURN(-1) ;
01916 
01917    if( val == 0.0 ){
01918      char clabel[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" ;
01919      char str[8] ;
01920      sprintf(str,"%c.+",clabel[ic]) ;
01921      RETURN( AFNI_set_func_autorange(str) ) ;
01922    }
01923 
01924    MCW_set_bbox( im3d->vwid->func->range_bbox , 0 ) ;   /* autoRange box off */
01925    im3d->vinfo->use_autorange = 0 ;
01926 
01927    AV_SENSITIZE( im3d->vwid->func->range_av , 1 ) ;
01928    AV_assign_fval( im3d->vwid->func->range_av , val ) ;
01929    AFNI_range_av_CB( im3d->vwid->func->range_av , im3d ) ;
01930    RETURN(0) ;
01931 }

int AFNI_set_func_resam char *    cmd [static]
 

SET_FUNC_RESAM [c.]{NN|Li|Cu|Bk}.{NN|Li|Cu|Bk} "SET_FUNC_RESAM A.Li.Li" ---------------------------------------------------------------------------

Definition at line 1969 of file afni_driver.c.

References AFNI_controller_code_to_index(), AFNI_resam_av_CB(), AV_assign_ival(), Three_D_View::b123_fim, Three_D_View::b231_fim, Three_D_View::b312_fim, AFNI_library_type::controllers, AFNI_widget_set::dmode, ENTRY, AFNI_datamode_widgets::func_resam_av, AFNI_view_info::func_resam_mode, GLOBAL_library, IM3D_OPEN, FD_brick::resam_code, RETURN, AFNI_datamode_widgets::thr_resam_av, FD_brick::thr_resam_code, AFNI_view_info::thr_resam_mode, Three_D_View::vinfo, and Three_D_View::vwid.

01970 {
01971    int ic , dadd=2 , fr=-1 , tr=-1 ;
01972    Three_D_View *im3d ;
01973 
01974 ENTRY("AFNI_set_func_resam") ;
01975 
01976    if( cmd == NULL || strlen(cmd) < 2 ) RETURN(-1) ;
01977 
01978    ic = AFNI_controller_code_to_index( cmd ) ;
01979    if( ic < 0 ){ ic = 0 ; dadd = 0 ; }
01980 
01981    im3d = GLOBAL_library.controllers[ic] ;
01982    if( !IM3D_OPEN(im3d) ) RETURN(-1) ;
01983 
01984         if( cmd[dadd] == 'N' && cmd[dadd+1] == 'N' ) fr = 0 ;
01985    else if( cmd[dadd] == 'L' && cmd[dadd+1] == 'i' ) fr = 1 ;
01986    else if( cmd[dadd] == 'C' && cmd[dadd+1] == 'u' ) fr = 2 ;
01987    else if( cmd[dadd] == 'B' && cmd[dadd+1] == 'k' ) fr = 2 ;
01988    else                                              RETURN(-1);
01989 
01990    if( cmd[dadd+2] == '.' ){
01991      dadd += 3 ;
01992           if( cmd[dadd] == 'N' && cmd[dadd+1] == 'N' ) tr = 0 ;
01993      else if( cmd[dadd] == 'L' && cmd[dadd+1] == 'i' ) tr = 1 ;
01994      else if( cmd[dadd] == 'C' && cmd[dadd+1] == 'u' ) tr = 2 ;
01995      else if( cmd[dadd] == 'B' && cmd[dadd+1] == 'k' ) tr = 2 ;
01996      else                                              RETURN(-1);
01997    }
01998 
01999    AV_assign_ival( im3d->vwid->dmode->func_resam_av , fr ) ;
02000    im3d->vinfo->func_resam_mode = fr ;
02001    if( im3d->b123_fim != NULL )
02002      im3d->b123_fim->resam_code =
02003       im3d->b231_fim->resam_code =
02004        im3d->b312_fim->resam_code = im3d->vinfo->func_resam_mode ;
02005 
02006    if( tr >= 0 ){
02007      AV_assign_ival( im3d->vwid->dmode->thr_resam_av , fr ) ;
02008      im3d->vinfo->thr_resam_mode = tr ;
02009      if( im3d->b123_fim != NULL )
02010        im3d->b123_fim->thr_resam_code =
02011         im3d->b231_fim->thr_resam_code =
02012          im3d->b312_fim->thr_resam_code = im3d->vinfo->thr_resam_mode ;
02013    }
02014 
02015    AFNI_resam_av_CB( NULL , im3d ) ;
02016    RETURN(0) ;
02017 }

int AFNI_set_func_visible char *    cmd [static]
 

SET_FUNC_VISIBLE [c.]{+|-} "SET_FUNC_VISIBLE A.+" ---------------------------------------------------------------------------

Definition at line 1938 of file afni_driver.c.

References AFNI_controller_code_to_index(), AFNI_see_func_CB(), AFNI_library_type::controllers, ENTRY, GLOBAL_library, IM3D_OPEN, MCW_set_bbox(), RETURN, AFNI_viewing_widgets::see_func_bbox, AFNI_widget_set::view, and Three_D_View::vwid.

01939 {
01940    int ic , dadd=2 , nn ;
01941    Three_D_View *im3d ;
01942 
01943 ENTRY("AFNI_set_func_visible") ;
01944 
01945    if( cmd == NULL || strlen(cmd) < 1 ) RETURN(-1) ;
01946 
01947    ic = AFNI_controller_code_to_index( cmd ) ;
01948    if( ic < 0 ){ ic = 0 ; dadd = 0 ; }
01949 
01950    im3d = GLOBAL_library.controllers[ic] ;
01951    if( !IM3D_OPEN(im3d) ) RETURN(-1) ;
01952 
01953    switch( cmd[dadd] ){
01954      default: RETURN(-1) ;
01955      case '+': nn = 1 ; break ;
01956      case '-': nn = 0 ; break ;
01957    }
01958 
01959    MCW_set_bbox( im3d->vwid->view->see_func_bbox , nn ) ;
01960    AFNI_see_func_CB( NULL , im3d , NULL ) ;
01961    RETURN(0) ;
01962 }

int AFNI_sleeper char *    cmd [static]
 

SLEEP msec

Definition at line 2022 of file afni_driver.c.

References RWC_sleep().

02023 {
02024    int ms=-1 ;
02025    if( cmd == NULL || strlen(cmd) < 1 ) return(-1) ;
02026    sscanf( cmd , "%d" , &ms ) ;
02027    if( ms > 0 ) RWC_sleep( ms ) ;
02028    return(0) ;
02029 }

int find_empty_graph_xy void    [static]
 

Definition at line 917 of file afni_driver.c.

References malloc, num_Graph_xy, and realloc.

Referenced by AFNI_drive_open_graph_1D(), and AFNI_drive_open_graph_xy().

00918 {
00919    int ii ;
00920 
00921    /* nothing in list ==> make a new list */
00922 
00923    if( Graph_xy_list == NULL ){
00924       Graph_xy_list    = (Graph_xy **) malloc(sizeof(Graph_xy *)) ;
00925       Graph_xy_list[0] = NULL ;
00926       num_Graph_xy     = 1 ;
00927       return 0 ;
00928    }
00929 
00930    /* search list for an empty element */
00931 
00932    for( ii=0 ; ii < num_Graph_xy ; ii++ )
00933       if( Graph_xy_list[ii] == NULL ) return ii ;
00934 
00935    /* add empty element to list */
00936 
00937    Graph_xy_list = (Graph_xy **) realloc( Graph_xy_list ,
00938                                           sizeof(Graph_xy *)*(num_Graph_xy+1) ) ;
00939    Graph_xy_list[num_Graph_xy] = NULL ;
00940    num_Graph_xy++ ;
00941    return (num_Graph_xy-1) ;
00942 }

int find_graph_xy_name char *    name [static]
 

Definition at line 899 of file afni_driver.c.

References name, and num_Graph_xy.

Referenced by AFNI_drive_addto_graph_1D(), AFNI_drive_addto_graph_xy(), AFNI_drive_clear_graph_1D(), AFNI_drive_clear_graph_xy(), AFNI_drive_close_graph_xy(), AFNI_drive_geom_graph(), AFNI_drive_open_graph_1D(), and AFNI_drive_open_graph_xy().

00900 {
00901    int ii ;
00902 
00903    if( name == NULL || name[0] == '\0' ) return -1 ;
00904 
00905    for( ii=0 ; ii < num_Graph_xy ; ii++ )
00906       if( Graph_xy_list[ii] != NULL                  &&
00907           strcmp(Graph_xy_list[ii]->gname,name) == 0   ) return ii ;
00908 
00909    return -1 ;
00910 }

void kill_graph_xy MEM_topshell_data   mp [static]
 

Definition at line 948 of file afni_driver.c.

References free, Graph_xy::last_y, Graph_xy::mp, mp, num_Graph_xy, and MEM_topshell_data::userdata.

Referenced by AFNI_drive_open_graph_1D(), and AFNI_drive_open_graph_xy().

00949 {
00950    int ii ;
00951 
00952    if( mp == NULL || Graph_xy_list == NULL ) return ;
00953 
00954    /* find this graph in the list */
00955 
00956    for( ii=0 ; ii < num_Graph_xy ; ii++ )
00957       if( Graph_xy_list[ii]     != NULL &&
00958           Graph_xy_list[ii]->mp == mp     ) break ;
00959 
00960    if( ii >= num_Graph_xy ) return ;  /* should not happen */
00961 
00962    /* free data from this graph */
00963 
00964    if( Graph_xy_list[ii]->last_y != NULL )
00965       free( Graph_xy_list[ii]->last_y ) ;
00966 
00967    if( mp->userdata != NULL ) free(mp->userdata) ;
00968 
00969    free( Graph_xy_list[ii] ) ; Graph_xy_list[ii] = NULL ; return ;
00970 }

Variable Documentation

AFNI_driver_pair dpair[] [static]
 

Definition at line 73 of file afni_driver.c.

Graph_xy** Graph_xy_list = NULL [static]
 

Definition at line 893 of file afni_driver.c.

int num_Graph_xy = 0 [static]
 

Definition at line 892 of file afni_driver.c.

Referenced by find_empty_graph_xy(), find_graph_xy_name(), and kill_graph_xy().

 

Powered by Plone

This site conforms to the following standards: