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_plugin.h

Go to the documentation of this file.
00001 /*****************************************************************************
00002    Major portions of this software are copyrighted by the Medical College
00003    of Wisconsin, 1994-2000, and are released under the Gnu General Public
00004    License, Version 2.  See the file README.Copyright for details.
00005 ******************************************************************************/
00006 
00007 #ifndef _AFNI_PLUGIN_HEADER_
00008 #define _AFNI_PLUGIN_HEADER_
00009 
00010 /*-----------------------------------------------------------------
00011   Most of this file is included only if ALLOW_PLUGINS is defined,
00012   but a little at the end is always used.
00013 -------------------------------------------------------------------*/
00014 
00015 #define PLUTO_X11_display   (GLOBAL_library.dc->display)
00016 #define PLUTO_Xt_appcontext (GLOBAL_library.dc->appcontext)
00017 
00018 #ifdef ALLOW_PLUGINS
00019 
00020 #if defined(__cplusplus) || defined(c_plusplus)
00021 # define DEFINE_PLUGIN_PROTOTYPE \
00022   extern "C" { PLUGIN_interface * PLUGIN_init( int ncall ) ; }
00023 #else
00024 # define DEFINE_PLUGIN_PROTOTYPE
00025 #endif
00026 
00027 
00028 #include <sys/types.h>
00029 #include <stdio.h>
00030 #include <stdlib.h>
00031 #include <string.h>
00032 #include <math.h>
00033 #include <sys/time.h>
00034 #include <sys/errno.h>
00035 #include <sys/times.h>
00036 #include <limits.h>
00037 
00038 struct AFNI_plugin_array ; /* incomplete definition */
00039 
00040 #include "afni.h"
00041 
00042 #include <Xm/XmAll.h>
00043 
00044 /*******************************************************************
00045    Define macros and typedefs for opening, closing, and finding
00046    symbols from dynamic libraries.  This is not done the same
00047    way on all Unixoid systems, unfortunately (that is to say,
00048    HP-UX is different).
00049 *******************************************************************/
00050 
00051 typedef int int_func() ;     /* generic function returning integer */
00052 typedef void * vptr_func() ; /* generic function returning void *  */
00053 typedef char * cptr_func() ; /* generic function returning char *  */
00054 
00055 /***************** The dlfcn.h and dl library ****************/
00056 
00057 #ifdef DYNAMIC_LOADING_VIA_DL
00058 
00059 #ifndef DARWIN
00060 #  include <dlfcn.h>
00061 #else
00062 #  include "dlcompat/dlfcn.h"
00063 #endif
00064 
00065    typedef void * DYNAMIC_handle ;
00066 
00067 #  define ISVALID_DYNAMIC_handle(handle) ((handle) != (DYNAMIC_handle) 0)
00068 
00069 #  define DYNAMIC_OPEN(libname,handle) \
00070       (handle) = dlopen( (libname) , RTLD_LAZY )
00071 
00072 #  define DYNAMIC_ERROR_STRING  dlerror()  /* 18 May 2001 */
00073 
00074 #  define DYNAMIC_CLOSE(handle) \
00075       (void) dlclose( (handle) )
00076 
00077 #  define DYNAMIC_SYMBOL(handle,symbol,address) \
00078       (address) = dlsym( (handle) , (symbol) )
00079 
00080 #  define DYNAMIC_suffix ".so"
00081 #endif
00082 
00083 /****************** The dl.h and dld library ******************/
00084 
00085 #ifdef DYNAMIC_LOADING_VIA_SHL
00086 #  include <dl.h>
00087 #  include <errno.h>  /* 18 May 2001 */
00088 
00089    typedef shl_t DYNAMIC_handle ;
00090 
00091 #  define ISVALID_DYNAMIC_handle(handle) ((handle) != (DYNAMIC_handle) 0)
00092 
00093 #  define DYNAMIC_OPEN(libname,handle) \
00094       (handle) = shl_load( (libname) , BIND_DEFERRED , 0L )
00095 
00096 #  define DYNAMIC_ERROR_STRING strerror(errno) /* 18 May 2001 */
00097 
00098 #  define DYNAMIC_CLOSE(handle) \
00099       (void) shl_unload( (handle) )
00100 
00101 #  define DYNAMIC_SYMBOL(handle,symbol,address)      \
00102       do{ (address) = NULL ;                         \
00103           (void) shl_findsym( &(handle) , (symbol) , \
00104                               TYPE_UNDEFINED , &(address) ) ; } while(0)
00105 
00106 #  define DYNAMIC_suffix ".sl"
00107 #endif
00108 
00109 #ifdef NO_DYNAMIC_LOADING             /* this stuff is not actually used,  */
00110 #  define DYNAMIC_suffix ".fixed"     /* but is needed to make things cool */
00111    typedef int DYNAMIC_handle ;       /* with the C compiler               */
00112 #endif
00113 
00114 #ifndef DYNAMIC_suffix
00115 #  error "Plugins not properly set up -- see machdep.h"
00116 #endif
00117 
00118 /*****************************************************************
00119    Data to define the interface between a plugin and AFNI
00120 ******************************************************************/
00121 
00122 /* dimensions of various arrays */
00123 
00124 #define PLUGIN_LABEL_SIZE           32  /* for buttons and menus */
00125 #define PLUGIN_STRING_SIZE          64  /* longer things */
00126 
00127 #if 1
00128 #define PLUGIN_MAX_STRING_RANGE     99  /* isn't this enough? */
00129 #else
00130 #define PLUGIN_MAX_STRING_RANGE     34  /* isn't this enough? */
00131 #endif
00132 
00133 #define PLUGIN_MAX_SUBVALUES         7  /* isn't this enough? */
00134                                         /*  -- Nope --  03 May 2002 [BDWard] */
00135 
00136 /* data type codes (not all are implemented yet!) */
00137 
00138 #define PLUGIN_NOTHING_TYPE          0
00139 #define PLUGIN_NUMBER_TYPE           1  /* implemented */
00140 #define PLUGIN_STRING_TYPE           2  /* implemented */
00141 #define PLUGIN_DATASET_TYPE          3  /* implemented */
00142 #define PLUGIN_DATASET_LIST_TYPE     4
00143 #define PLUGIN_TIMESERIES_TYPE       5  /* implemented */
00144 #define PLUGIN_TIMESERIES_LIST_TYPE  6
00145 #define PLUGIN_2DIMAGE_TYPE          7
00146 #define PLUGIN_2DIMAGE_LIST_TYPE     8
00147 #define PLUGIN_3DIMAGE_TYPE          9
00148 #define PLUGIN_3DIMAGE_LIST_TYPE    10
00149 #define PLUGIN_4DIMAGE_TYPE         11
00150 #define PLUGIN_4DIMAGE_LIST_TYPE    12
00151 #define PLUGIN_OVERLAY_COLOR_TYPE   13
00152 
00153 /** macro to copy string into plugin label array,
00154     filling with blanks or truncating length, as needed **/
00155 
00156 #define PLUGIN_LABEL_strcpy(plab,str)                                \
00157    do{ int ll=strlen((str)) , ii ;                                   \
00158        if( ll >= PLUGIN_LABEL_SIZE ) ll = PLUGIN_LABEL_SIZE - 1 ;    \
00159        for( ii=0 ; ii < ll ; ii++ ) (plab)[ii] = (str)[ii] ;         \
00160        for( ; ii < PLUGIN_LABEL_SIZE - 1 ; ii++ ) (plab)[ii] = ' ' ; \
00161        plab[PLUGIN_LABEL_SIZE - 1] = '\0' ; } while(0)
00162 
00163 /** prototype of routine to compute length
00164     of string, not counting blanks at the end **/
00165 
00166 extern int PLUG_nonblank_len(char *) ;
00167 
00168 /******* typedef to hold data describing
00169          each subvalue that an option requires *******/
00170 
00171 typedef struct {
00172    int data_type ;  /* one of the PLUGIN_*_TYPE codes above */
00173 
00174    char label[PLUGIN_LABEL_SIZE] ;  /* label for AFNI to display */
00175    char * hint ;
00176 
00177    /** values describing the range of acceptable inputs **/
00178 
00179    int int_range_bot , int_range_top , int_range_decim ; /* for NUMBER */
00180 
00181    int    string_range_count ;                           /* for STRING */
00182    char * string_range[PLUGIN_MAX_STRING_RANGE] ;
00183 
00184    int dset_anat_mask , dset_func_mask , dset_ctrl_mask ; /* for DATASET */
00185 
00186    /** the default value to set up the interface with **/
00187 
00188    int value_default ;  /* for NUMBER or STRING */
00189 
00190    /** values describing other properties of the input **/
00191 
00192    int editable ;  /* can the user type into this? */
00193 
00194 } PLUGIN_subvalue ;
00195 
00196 /****** typedef to hold data describing
00197         each option input line to a plugin ******/
00198 
00199 typedef struct {
00200    char label[PLUGIN_LABEL_SIZE] ;  /* label for AFNI to display */
00201    char tag[PLUGIN_STRING_SIZE] ;   /* passed to plugin */
00202    char * hint ;
00203 
00204    int subvalue_count ;                              /* number of subvalues */
00205    PLUGIN_subvalue subvalue[PLUGIN_MAX_SUBVALUES] ;  /* subvalue descriptors */
00206 
00207    int mandatory ;  /* required by law? */
00208 
00209    int    chosen ;
00210    void * callvalue[PLUGIN_MAX_SUBVALUES] ; /* actual values given to plugin */
00211 } PLUGIN_option ;
00212 
00213 /******* typedef to describe the option-level
00214          widgets for the interface to a plugin *******/
00215 
00216 #define OP_CHOOSER_NONE       0   /* nothing                      */
00217 #define OP_CHOOSER_DSET       1   /* PushButton                   */
00218 #define OP_CHOOSER_OPTMENU    2   /* optmenu type of MCW_arrowval */
00219 #define OP_CHOOSER_STRING     3   /* string type of MCW_arrowval  */
00220 #define OP_CHOOSER_NUMBER     4   /* number type of MCW_arrowval  */
00221 #define OP_CHOOSER_TEXTFIELD  5   /* TextField                    */
00222 #define OP_CHOOSER_TIMESERIES 6   /* PushButton                   */
00223 #define OP_CHOOSER_COLORMENU  7   /* optmenu for overlay colors   */
00224 
00225 #define OP_OPTMENU_LIMIT     99
00226 #define OP_OPTMENU_COLSIZE   20
00227 
00228 typedef struct {
00229    Widget rowcol , label , textf ;
00230 } PLUGIN_strval ;
00231 
00232 typedef struct {
00233    char       title[THD_MAX_NAME] ;
00234    MCW_idcode idcode ;
00235 } PLUGIN_dataset_link ;
00236 
00237 extern void make_PLUGIN_dataset_link( THD_3dim_dataset *, PLUGIN_dataset_link * ) ;
00238 extern void patch_PLUGIN_dataset_links( int , PLUGIN_dataset_link * ) ;
00239 
00240 typedef struct {
00241    Widget rowcol , label , pb ;
00242 
00243    int                   dset_count ;  /* number of datasets to display */
00244    PLUGIN_dataset_link * dset_link ;   /* info about them */
00245    PLUGIN_subvalue     * sv ;          /* my good friend */
00246 
00247    int dset_choice ;                   /* the chosen index */
00248 
00249    int multi , nchosen , * chosen ;    /* 24 Nov 1996: for dataset lists */
00250    int current ;
00251    MCW_idcode * idclist ;
00252 } PLUGIN_dsetval ;
00253 
00254 typedef PLUGIN_dsetval MCW_idclist ;
00255 
00256 typedef struct {
00257    Widget rowcol , label , pb ;
00258 
00259    MRI_IMARR       * tsimar ;    /* array of time series to choose from */
00260    PLUGIN_subvalue * sv ;        /* my good friend */
00261 
00262    MRI_IMAGE * tsim ;            /* the chosen timeseries */
00263    int         ts_choice ;       /* the chosen index */
00264 } PLUGIN_tsval ;
00265 
00266 typedef struct {
00267    Widget toggle , label ;
00268    void * chooser[PLUGIN_MAX_SUBVALUES] ;
00269    Widget chtop[PLUGIN_MAX_SUBVALUES] ;
00270    int    chooser_type[PLUGIN_MAX_SUBVALUES] ;
00271 } PLUGIN_option_widgets ;
00272 
00273 /******* typedef to describe the top-level
00274          widgets for the interface to a plugin *******/
00275 
00276 typedef struct {
00277    Widget shell , form , label , scrollw , workwin ;
00278    PLUGIN_option_widgets ** opwid ;
00279    Widget meter ;
00280 } PLUGIN_widgets ;
00281 
00282 /******* typedef to describe
00283          the interface to a plugin *******/
00284 
00285 #define PLUGIN_CALL_IMMEDIATELY  77
00286 #define PLUGIN_CALL_VIA_MENU     88
00287 #define PLUGIN_CALL_VIA_CUSTOM   99
00288 
00289 typedef struct PLUGIN_interface {
00290    char label[PLUGIN_LABEL_SIZE] ;         /* for a button */
00291    char description[PLUGIN_STRING_SIZE] ;  /* for the interface panel */
00292    char * helpstring ;                     /* from the user? */
00293    char * hint ;
00294 
00295    int         call_method ;  /* one of the PLUGIN_CALL_* codes above */
00296    cptr_func * call_func ;    /* function to call */
00297 
00298    int option_count ;         /* number of option lines */
00299    PLUGIN_option ** option ;  /* array of option line descriptors */
00300    PLUGIN_widgets * wid ;     /* toplevel widgets for this interface */
00301 
00302    Three_D_View * im3d ;      /* who called me up? */
00303 
00304    int opnum , svnum ;        /* used during get_*_from readout */
00305 
00306    char seqcode[PLUGIN_STRING_SIZE] ;  /* 06 Aug 1999 */
00307    char butcolor[PLUGIN_STRING_SIZE] ; /* 01 Nov 1999 */
00308 
00309    int  flags ;                        /* 29 Mar 2002 */
00310 
00311    char run_label [PLUGIN_LABEL_SIZE] ; /* 04 Nov 2003 */
00312    char doit_label[PLUGIN_LABEL_SIZE] ;
00313 } PLUGIN_interface ;
00314 
00315 #define SHORT_CHOOSE_FLAG 1
00316 #define SHORT_NUMBER_FLAG 2
00317 
00318 #define PLUTO_short_choose(pl) (pl->flags |= SHORT_CHOOSE_FLAG)
00319 #define PLUTO_short_number(pl) (pl->flags |= SHORT_NUMBER_FLAG)
00320 
00321 /*************** Prototypes for creation of the above structures ***************/
00322 
00323 #define SESSION_ALL_MASK      (1<<0)
00324 
00325 #define ANAT_NONE_MASK        0
00326 #define FUNC_NONE_MASK        0
00327 
00328 #define DIMEN_3D_MASK         (1<<1)
00329 #define DIMEN_4D_MASK         (1<<2)
00330 #define DIMEN_ALL_MASK        (DIMEN_3D_MASK | DIMEN_4D_MASK)
00331 
00332 #define WARP_ON_DEMAND_MASK   (1<<3)
00333 
00334 #define BRICK_BYTE_MASK       (1<<8)
00335 #define BRICK_SHORT_MASK      (1<<9)
00336 #define BRICK_FLOAT_MASK      (1<<10)
00337 #define BRICK_COMPLEX_MASK    (1<<11)
00338 #define BRICK_RGB_MASK        (1<<12)
00339 #define BRICK_ALLTYPE_MASK    ( BRICK_BYTE_MASK  | BRICK_SHORT_MASK   |  \
00340                                 BRICK_FLOAT_MASK | BRICK_COMPLEX_MASK |  \
00341                                 BRICK_RGB_MASK                         )
00342 
00343 #define BRICK_ALLREAL_MASK    ( BRICK_BYTE_MASK  | BRICK_SHORT_MASK |    \
00344                                 BRICK_FLOAT_MASK )
00345 
00346 extern int PLUGIN_dset_check( int,int    , THD_3dim_dataset * ) ;
00347 extern int PLUTO_dset_check ( int,int,int, THD_3dim_dataset * ) ;
00348 
00349 #define PLUTO_add_option         add_option_to_PLUGIN_interface
00350 #define PLUTO_add_number         add_number_to_PLUGIN_interface
00351 #define PLUTO_add_string         add_string_to_PLUGIN_interface
00352 #define PLUTO_add_dataset        add_dataset_to_PLUGIN_interface
00353 #define PLUTO_add_timeseries     add_timeseries_to_PLUGIN_interface
00354 #define PLUTO_add_dataset_list   add_dataset_list_to_PLUGIN_interface
00355 #define PLUTO_add_overlaycolor   add_overlaycolor_to_PLUGIN_interface
00356 
00357 #define PLUTO_register_environment_numeric ENV_add_numeric     /* 20 Jun 2000 */
00358 #define PLUTO_register_environment_string  ENV_add_string
00359 #define PLUTO_register_environment_yesno   ENV_add_yesno       /* 08 Aug 2001 */
00360 
00361 extern void PLUTO_add_hint( PLUGIN_interface * , char * ) ;
00362 
00363 extern void PLUTO_set_sequence( PLUGIN_interface *, char * ) ; /* 06 Aug 1999 */
00364 extern void PLUTO_set_butcolor( PLUGIN_interface *, char * ) ; /* 01 Nov 1999 */
00365 
00366 /* 15 Jun 1999: redo PLUTO_new_interface */
00367 
00368 #define PLUTO_new_interface(a,b,c,d,e) new_PLUGIN_interface_1999(a,b,c,d,e,__DATE__)
00369 
00370 extern PLUGIN_interface * new_PLUGIN_interface( char *, char *, char *,
00371                                                 int, cptr_func * ) ;
00372 
00373 extern PLUGIN_interface * new_PLUGIN_interface_1999( char *, char *, char *,
00374                                                      int, cptr_func * , char * ) ;
00375 
00376 void PLUTO_set_runlabels( PLUGIN_interface *, char *, char * ) ; /* 04 Nov 2003 */
00377 
00378 extern void add_option_to_PLUGIN_interface( PLUGIN_interface *,
00379                                             char *, char *, int ) ;
00380 
00381 extern void add_number_to_PLUGIN_interface( PLUGIN_interface *, char *,
00382                                             int, int, int, int, int ) ;
00383 
00384 extern void add_string_to_PLUGIN_interface( PLUGIN_interface *,
00385                                             char *, int, char **, int) ;
00386 
00387 extern void add_dataset_to_PLUGIN_interface( PLUGIN_interface *,
00388                                              char *, int,int,int ) ;
00389 
00390 extern void add_dataset_list_to_PLUGIN_interface( PLUGIN_interface *,
00391                                                   char *, int,int,int ) ;
00392 
00393 extern void add_timeseries_to_PLUGIN_interface( PLUGIN_interface *, char * ) ;
00394 
00395 extern void add_overlaycolor_to_PLUGIN_interface( PLUGIN_interface *, char * );
00396 
00397 extern void PLUG_fillin_values( PLUGIN_interface * plint ) ;
00398 extern void PLUG_freeup_values( PLUGIN_interface * plint ) ;
00399 
00400 extern char * PLUTO_commandstring( PLUGIN_interface * plint ) ;
00401 
00402 #define PLUTO_get_label        get_label_from_PLUGIN_interface
00403 #define PLUTO_get_descripton   get_description_from_PLUGIN_interface
00404 #define PLUTO_get_optiontag    get_optiontag_from_PLUGIN_interface
00405 #define PLUTO_get_callvalue    get_callvalue_from_PLUGIN_interface
00406 #define PLUTO_get_number       get_number_from_PLUGIN_interface
00407 #define PLUTO_get_string       get_string_from_PLUGIN_interface
00408 #define PLUTO_get_idcode       get_idcode_from_PLUGIN_interface
00409 #define PLUTO_get_timeseries   get_timeseries_from_PLUGIN_interface
00410 #define PLUTO_peek_callvalue   peek_callvalue_type_from_PLUGIN_interface
00411 #define PLUTO_peek_optiontag   peek_optiontag_from_PLUGIN_interface
00412 #define PLUTO_get_idclist      get_idclist_from_PLUGIN_interface
00413 #define PLUTO_get_overlaycolor get_overlaycolor_from_PLUGIN_interface
00414 
00415 #define PLUTO_idclist_count(ll) ( ((ll) != NULL) ? (ll)->nchosen : 0 )
00416 #define PLUTO_idclist_reset(ll) ((ll)->current = 0)
00417 #define PLUTO_idclist_next(ll)  (((ll)->current < (ll)->nchosen)     \
00418                                  ? ((ll)->idclist+((ll)->current)++) : NULL)
00419 
00420 extern char * get_label_from_PLUGIN_interface       ( PLUGIN_interface * ) ;
00421 extern char * get_description_from_PLUGIN_interface ( PLUGIN_interface * ) ;
00422 extern char * get_optiontag_from_PLUGIN_interface   ( PLUGIN_interface * ) ;
00423 extern void * get_callvalue_from_PLUGIN_interface   ( PLUGIN_interface * , int ) ;
00424 extern float  get_number_from_PLUGIN_interface      ( PLUGIN_interface * ) ;
00425 extern char * get_string_from_PLUGIN_interface      ( PLUGIN_interface * ) ;
00426 extern int    get_overlaycolor_from_PLUGIN_interface( PLUGIN_interface * ) ;
00427 
00428 extern MCW_idcode * get_idcode_from_PLUGIN_interface( PLUGIN_interface * ) ;
00429 extern MRI_IMAGE * get_timeseries_from_PLUGIN_interface( PLUGIN_interface * ) ;
00430 extern MCW_idclist * get_idclist_from_PLUGIN_interface( PLUGIN_interface * ) ;
00431 
00432 extern int    peek_callvalue_type_from_PLUGIN_interface( PLUGIN_interface * ) ;
00433 extern char * peek_optiontag_from_PLUGIN_interface     ( PLUGIN_interface * ) ;
00434 
00435 #define NEXT_PLUGIN_OPTION(pl) (void)get_optiontag_from_PLUGIN_interface((pl))
00436 #define NEXT_OPTION            NEXT_PLUGIN_OPTION
00437 #define PLUTO_next_option      NEXT_PLUGIN_OPTION
00438 
00439 #define BAD_NUMBER        (-31416.666)
00440 #define PLUTO_BAD_NUMBER  BAD_NUMBER
00441 
00442 /**************************************************************************/
00443 /***** Define data structures to hold control information for plugins *****/
00444 
00445 #define AFNI_PLUGIN_TYPE        9754
00446 #define ISVALID_AFNI_PLUGIN(pl) ((pl)!=NULL && (pl)->type==AFNI_PLUGIN_TYPE)
00447 
00448 #define MAX_PLUGIN_NAME 128
00449 
00450 /*** one plugin ***/
00451 
00452 typedef struct {
00453    int type ;     /* identifier */
00454 
00455    char           libname[MAX_PLUGIN_NAME] ;
00456    DYNAMIC_handle libhandle ;
00457    vptr_func    * libinit_func ;
00458 
00459    int                 interface_count ;
00460    PLUGIN_interface ** interface ;
00461 
00462    char seqcode[PLUGIN_STRING_SIZE] ;  /* 06 Aug 1999 */
00463 } AFNI_plugin ;
00464 
00465 /*** dynamic array of many plugins ***/
00466 
00467 typedef struct AFNI_plugin_array {
00468    int num , nall ;
00469    AFNI_plugin ** plar ;
00470 } AFNI_plugin_array ;
00471 
00472 /*** macros to create, add to, destroy, and free an array of plugins ***/
00473 
00474 #define INC_PLUGIN_ARRAY 8
00475 
00476 /** "name" is a variable of type (AFNI_plugin_array *) **/
00477 
00478 #define INIT_PLUGIN_ARRAY(name)                                                     \
00479    do{ int iq ;                                                                     \
00480        (name)       = (AFNI_plugin_array *) malloc(sizeof(AFNI_plugin_array)) ;     \
00481        (name)->num  = 0 ;                                                           \
00482        (name)->nall = INC_PLUGIN_ARRAY ;                                            \
00483        (name)->plar = (AFNI_plugin **)malloc(sizeof(AFNI_plugin*)*(name)->nall) ;   \
00484        for( iq=(name)->num ; iq < (name)->nall ; iq++ ) (name)->plar[iq] = NULL ;   \
00485      } while(0)
00486 
00487 /** "plug" is a variable of type (AFNI_plugin *) **/
00488 
00489 #define ADDTO_PLUGIN_ARRAY(name,plug)                                                 \
00490    do{ int nn , iq ;                                                                  \
00491        if( (name)->num == (name)->nall ){                                             \
00492           nn = (name)->nall = 1.1*(name)->nall + INC_PLUGIN_ARRAY ;                   \
00493           (name)->plar      = (AFNI_plugin **)                                        \
00494                                realloc( (name)->plar,sizeof(AFNI_plugin *)*nn ) ;     \
00495           for( iq=(name)->num ; iq < (name)->nall ; iq++ ) (name)->plar[iq] = NULL ;} \
00496        nn = (name)->num ; ((name)->num)++ ;                                           \
00497        (name)->plar[nn] = (plug) ;                                                    \
00498      } while(0)
00499 
00500 /** this frees all the memory associated with this array **/
00501 
00502 #define DESTROY_PLUGIN_ARRAY(name)                                      \
00503    do{ int nn ;                                                         \
00504        if( (name) != NULL ){                                            \
00505           for( nn=0 ; nn < (name)->num ; nn++ )                         \
00506              if( (name)->plar[nn] != NULL ) free( (name)->plar[nn] ) ;  \
00507           free( (name)->plar ) ; free((name)) ; (name) = NULL ;         \
00508        } } while(0)
00509 
00510 /** this just frees the control data associated
00511     with this array -- the actual plugins are not freed. **/
00512 
00513 #define FREE_PLUGIN_ARRAY(name)                                         \
00514    do{ int nn ;                                                         \
00515        if( (name) != NULL ){                                            \
00516           free( (name)->plar ) ; free((name)) ; (name) = NULL ;         \
00517        } } while(0)
00518 
00519 /*********************************************************************************/
00520 
00521 /***** Other prototypes *****/
00522 
00523 extern AFNI_plugin_array * PLUG_get_all_plugins( char * dname ) ;
00524 extern AFNI_plugin *       PLUG_read_plugin( char * fname ) ;
00525 extern AFNI_plugin_array * PLUG_get_many_plugins(char *) ;
00526 
00527 extern void PLUG_setup_widgets( PLUGIN_interface *, MCW_DC * ) ;
00528 
00529 extern void PLUG_action_CB           ( Widget , XtPointer , XtPointer ) ;
00530 extern void PLUG_delete_window_CB    ( Widget , XtPointer , XtPointer ) ;
00531 extern void PLUG_optional_toggle_CB  ( Widget , XtPointer , XtPointer ) ;
00532 extern void PLUG_choose_dataset_CB   ( Widget , XtPointer , XtPointer ) ;
00533 extern void PLUG_startup_plugin_CB   ( Widget , XtPointer , XtPointer ) ;
00534 extern void PLUG_choose_timeseries_CB( Widget , XtPointer , XtPointer ) ;
00535 
00536 extern void PLUTO_turnoff_options( PLUGIN_interface * ) ; /* 21 Feb 2001 */
00537 
00538 extern void PLUG_finalize_dataset_CB   (Widget, XtPointer, MCW_choose_cbs *);
00539 extern void PLUG_finalize_timeseries_CB(Widget, XtPointer, MCW_choose_cbs *);
00540 
00541 extern void PLUTO_popup_dset_chooser( Widget, int, int,
00542                                       int_func *, void_func *, void * ) ;
00543 
00544 extern void PLUG_finalize_user_dset_CB( Widget, XtPointer, MCW_choose_cbs * ) ;
00545 
00546 extern void AFNI_plugin_button( Three_D_View * ) ;
00547 
00548 #define DSET_ACTION_NONE           0
00549 #define DSET_ACTION_MAKE_CURRENT   1
00550 
00551 extern int PLUTO_add_dset( PLUGIN_interface *, THD_3dim_dataset *, int ) ;
00552 
00553 extern THD_3dim_dataset * PLUTO_copy_dset( THD_3dim_dataset *, char * ) ;
00554 
00555 extern void PLUTO_dset_redisplay_mode( THD_3dim_dataset * , int ) ;
00556 extern void PLUTO_dset_redisplay( THD_3dim_dataset * ) ;
00557 
00558 extern int PLUTO_prefix_ok( char * ) ;
00559 extern int PLUTO_string_index( char * , int , char ** ) ;
00560 
00561 #define PLUTO_popup_message(pl,ch)   \
00562    PLUTO_popup_worker((pl),(ch),MCW_USER_KILL)
00563 
00564 #define PLUTO_popup_transient(pl,ch) \
00565    PLUTO_popup_worker((pl),(ch),MCW_USER_KILL|MCW_TIMER_KILL);
00566 
00567 #define PLUTO_popup_textwin(pl,ch)   \
00568    PLUTO_popup_worker((pl),(ch),-1)
00569 
00570 extern void PLUTO_fixup_names(void) ;
00571 extern void PLUTO_popup_worker( PLUGIN_interface * , char * , int ) ;
00572 extern void PLUTO_beep(void) ;
00573 
00574 extern void PLUTO_popup_meter( PLUGIN_interface * ) ;
00575 extern void PLUTO_popdown_meter( PLUGIN_interface * ) ;
00576 extern void PLUTO_set_meter( PLUGIN_interface * , int ) ;
00577 
00578 extern void PLUTO_set_topshell( PLUGIN_interface *, Widget ) ; /* 22 Sep 2000 */
00579 
00580 /*------------------------------------------------------------------------*/
00581 
00582 typedef struct {
00583    MCW_imseq * seq ;
00584    MRI_IMAGE * im ;
00585 } PLUGIN_impopper ;
00586 
00587 extern void *    PLUTO_popup_image( void * , MRI_IMAGE * ) ;
00588 extern XtPointer PLUGIN_imseq_getim( int , int , XtPointer ) ;
00589 extern void      PLUGIN_seq_send_CB( MCW_imseq * , XtPointer , ISQ_cbs * ) ;
00590 
00591 #define PLUTO_popdown_image(hh) (void)PLUTO_popup_image((hh),NULL)
00592 
00593 #define PLUTO_popup_open(hh) \
00594    ( (hh) != NULL && ISQ_REALZ(((PLUGIN_impopper *)(hh))->seq) )
00595 
00596 #define PLUTO_popkill_image(hh) \
00597    ( PLUTO_popdown_image(hh) , XtFree((char *)(hh)) , (hh)=NULL )
00598 
00599 /*------------------------------------------------------------------------*/
00600 
00601 typedef struct {
00602    MCW_imseq * seq ;
00603    MRI_IMARR * imar ;
00604    int rgb_count ;
00605    generic_func * kill_func ;
00606    void * kill_data ;
00607 } PLUGIN_imseq ;
00608 
00609 extern void * PLUTO_imseq_popup( MRI_IMARR *, generic_func *, void * ) ;
00610 extern void * PLUTO_imseq_popim( MRI_IMAGE *, generic_func *, void * ) ;
00611 
00612 extern void   PLUTO_imseq_addto( void * , MRI_IMAGE * ) ;
00613 extern void   PLUTO_imseq_destroy( void * ) ;
00614 extern void   PLUTO_imseq_retitle( void * , char * ) ;
00615 extern void   PLUTO_imseq_rekill( void *, generic_func *, void * ) ;
00616 extern void   PLUTO_imseq_setim( void * , int ) ;  /* 17 Dec 2004 */
00617 
00618 extern XtPointer PLUTO_imseq_getim( int , int , XtPointer ) ;
00619 extern void PLUTO_imseq_send_CB( MCW_imseq * , XtPointer , ISQ_cbs * ) ;
00620 
00621 /*------------------------------------------------------------------------*/
00622 
00623 extern THD_3dim_dataset * PLUTO_4D_to_typed_fim( THD_3dim_dataset * old_dset ,
00624                                                  char * new_prefix , int new_datum ,
00625                                                  int ignore , int detrend ,
00626                                                  generic_func * user_func ,
00627                                                  void * user_data ) ;
00628 
00629 #define PLUTO_4D_to_fim(ds,np,ig,dtr,uf,ud) \
00630   PLUTO_4D_to_typed_fim( (ds),(np), MRI_short , (ig),(dtr),(uf),(ud) )
00631 
00632 /* BDW, 24 Feb 1997 */
00633 extern THD_3dim_dataset * PLUTO_4D_to_typed_fith( THD_3dim_dataset * old_dset ,
00634                                                   char * new_prefix , int new_datum ,
00635                                                   int ignore , int detrend ,
00636                                                   generic_func * user_func ,
00637                                                   void * user_data ) ;
00638 
00639 #define PLUTO_4D_to_fith(ds,np,ig,dtr,uf,ud) \
00640   PLUTO_4D_to_typed_fith( (ds),(np), MRI_short , (ig),(dtr),(uf),(ud) )
00641 
00642 /* RWC, 13 Dec 1997 */
00643 
00644 extern THD_3dim_dataset * PLUTO_4D_to_typed_fbuc( THD_3dim_dataset * old_dset ,
00645                                                   char * new_prefix , int new_datum ,
00646                                                   int ignore , int detrend ,
00647                                                   int nbrik ,
00648                                                   generic_func * user_func ,
00649                                                   void * user_data ) ;
00650 
00651 extern void PLUTO_report( PLUGIN_interface * , char * ) ;
00652 
00653 #define PLUTO_output_header(ds) THD_write_3dim_dataset(NULL,NULL,(ds),False)
00654 
00655 extern PLUGIN_strval * new_PLUGIN_strval( Widget , char * ) ;
00656 extern void destroy_PLUGIN_strval( PLUGIN_strval * ) ;
00657 extern void alter_PLUGIN_strval_width( PLUGIN_strval * , int ) ;
00658 extern void set_PLUGIN_strval( PLUGIN_strval * , char * ) ;
00659 extern char * get_PLUGIN_strval( PLUGIN_strval * ) ;
00660 
00661 /* for vol2surf plugin                                09 Sep 2004 [rickr] */
00662 extern int PLUTO_set_v2s_addrs(void ** vopt, char *** maps, char ** hist);
00663 
00664 
00665 #endif /* ALLOW_PLUGINS */
00666 
00667 /*--------------------------------------------------------------------
00668   Stuff that is always defined
00669 ----------------------------------------------------------------------*/
00670 
00671 #define PLUTO_extract_series(ijk,ds)     THD_extract_series((ijk),(ds),0)
00672 #define PLUTO_extract_series_raw(ijk,ds) THD_extract_series((ijk),(ds),1)
00673 
00674 #define PLUTO_register_0D_function  AFNI_register_0D_function
00675 #define PLUTO_register_1D_function  AFNI_register_1D_function
00676 #define PLUTO_register_2D_function  AFNI_register_2D_function
00677 
00678 #define PLUTO_register_1D_funcstr   AFNI_register_1D_funcstr
00679 
00680 #define PLUTO_cursorize(w)  NORMAL_cursorize(w)
00681 
00682 extern void PLUTO_register_timeseries( char * , MRI_IMAGE * ) ;
00683 
00684 extern THD_3dim_dataset * PLUTO_find_dset( MCW_idcode * ) ;
00685 extern THD_3dim_dataset * PLUTO_find_dset_idc( char * ) ;
00686 extern THD_slist_find     PLUTO_dset_finder( char * ) ;
00687 
00688 extern void PLUTO_histoplot( int, float, float, int *,
00689                              char *, char *, char * , int,int ** ) ;
00690 
00691 extern void PLUTO_scatterplot( int , float *, float *,
00692                                char *, char *, char * , float,float ) ;
00693 
00694 extern void PLUTO_force_redisplay( void ) ;
00695 extern void PLUTO_force_rebar( void ) ;
00696 
00697 extern void PLUTO_register_workproc( XtWorkProc , XtPointer ) ;
00698 extern void PLUTO_remove_workproc  ( XtWorkProc ) ;
00699 extern Boolean PLUG_workprocess( XtPointer ) ;
00700 extern void PLUTO_register_timeout( int, generic_func *, XtPointer ) ;
00701 extern double PLUTO_cpu_time(void) ;
00702 extern double PLUTO_elapsed_time(void) ;
00703 
00704 #endif /* _AFNI_PLUGIN_HEADER_ */
 

Powered by Plone

This site conforms to the following standards: