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_setup.c File Reference

#include "afni.h"

Go to the source code of this file.


Defines

#define ISTARRED(s)   ( (s)[0]=='*' && (s)[1]=='*' && (s)[2]=='*' )
#define EOLSKIP
#define GETSSS
#define GETSTR
#define GETEQN
#define NSBUF   256

Functions

int label_in_PALTAB (PBAR_palette_table *pt, char *lab)
void AFNI_process_setup (char *fname, int mode, MCW_DC *dc)
int check_PBAR_palette (PBAR_palette *pp)
char * dump_PBAR_palette_table (int verb)
void load_PBAR_palette_array (MCW_pbar *pbar, PBAR_palette_array *par, int fixim)
char * AFNI_palette_label_CB (MCW_arrowval *av, XtPointer cd)
void AFNI_pbar_EV (Widget w, XtPointer cd, XEvent *ev, Boolean *continue_to_dispatch)
void AFNI_pbar_CB (Widget w, XtPointer cd, XtPointer cbs)
void AFNI_palette_av_CB (MCW_arrowval *av, XtPointer cd)
void AFNI_finalize_read_palette_CB (Widget w, XtPointer cd, XtPointer cb)
void AFNI_set_pbar_top_CB (Widget wcaller, XtPointer cd, MCW_choose_cbs *cbs)
void AFNI_finalize_write_palette_CB (Widget wcaller, XtPointer cd, MCW_choose_cbs *cbs)
void AFNI_finalize_saveim_CB (Widget wcaller, XtPointer cd, MCW_choose_cbs *cbs)
void AFNI_palette_tran_CB (MCW_arrowval *av, XtPointer cd)

Define Documentation

#define EOLSKIP
 

Value:

do{ for( ; fptr[0] != '\n' && fptr[0] != '\0' ; fptr++ ) ;    \
      if( fptr[0] == '\0' ){ free(fbuf) ; EXRETURN ; }                   \
      fptr++ ; } while(0)

Definition at line 30 of file afni_setup.c.

#define GETEQN
 

Value:

do{ GETSTR ; if(ISTARRED(str)) goto SkipSection ;                       \
      strcpy(left,str) ;                                                  \
      GETSTR ; if(ISTARRED(str)) goto SkipSection ;                       \
      strcpy(middle,str) ;                                                \
      GETSTR ; if(ISTARRED(str)) goto SkipSection ;                       \
      strcpy(right,str) ; } while(0)

Definition at line 48 of file afni_setup.c.

Referenced by AFNI_process_setup().

#define GETSSS
 

Value:

do{ int nu=0,qq;                                                        \
      if( fptr-fbuf >= nbuf || fptr[0] == '\0' ){ free(fbuf); EXRETURN; } \
      str[0]='\0'; qq=sscanf(fptr,"%127s%n",str,&nu); nused+=nu;fptr+=nu; \
      if( str[0]=='\0' || qq==0 || nu==0 ){ free(fbuf); EXRETURN; }       \
    } while(0)

Definition at line 35 of file afni_setup.c.

#define GETSTR
 

Value:

do{ GETSSS ;                                                            \
      while(str[0]=='!' || (str[0]=='/' && str[1]=='/') ||                \
            (str[0]=='#' && str[1]=='\0') ){EOLSKIP; GETSSS;}             \
    } while(0)

Definition at line 42 of file afni_setup.c.

Referenced by AFNI_process_setup().

#define ISTARRED      ( (s)[0]=='*' && (s)[1]=='*' && (s)[2]=='*' )
 

Definition at line 28 of file afni_setup.c.

#define NSBUF   256
 

Definition at line 56 of file afni_setup.c.

Referenced by AFNI_process_setup().


Function Documentation

void AFNI_finalize_read_palette_CB Widget    w,
XtPointer    cd,
XtPointer    cb
 

Definition at line 700 of file afni_setup.c.

References AFNI_palette_av_CB(), AFNI_palette_label_CB(), AFNI_process_setup(), AFNI_suck_file(), AV_assign_ival(), BEEPIT, MCW_pbar::bigmode, AFNI_library_type::controllers, Three_D_View::dc, dump_PBAR_palette_table(), ENTRY, AFNI_widget_set::file_dialog, free, AFNI_widget_set::func, GLOBAL_library, GPT, IM3D_VALID, AFNI_function_widgets::inten_pbar, MAX_CONTROLLERS, MCW_popup_message(), MCW_TIMER_KILL, MCW_USER_KILL, AFNI_function_widgets::options_label, PALTAB_NUM, PBAR_define_bigmap(), AFNI_function_widgets::pbar_palette_av, refit_MCW_optmenu(), RWC_XtPopdown(), SETUP_LATER_MODE, THD_is_directory(), THD_is_file(), Three_D_View::vwid, MCW_arrowval::wrowcol, and XtFree.

Referenced by AFNI_pbar_CB().

00701 {
00702    Three_D_View * im3d = (Three_D_View *) cd ;
00703    XmFileSelectionBoxCallbackStruct * cbs = (XmFileSelectionBoxCallbackStruct *) cb ;
00704    char * dum ;
00705 
00706 ENTRY("AFNI_finalize_read_palette_CB") ;
00707 
00708    switch( cbs->reason ){
00709 
00710       /** close the file selection dialog **/
00711 
00712       case XmCR_CANCEL:
00713          RWC_XtPopdown( im3d->vwid->file_dialog ) ;
00714       break ;
00715 
00716       /** try to read a new palette **/
00717 
00718       case XmCR_OK:{
00719          char * text = NULL ;
00720          int ii , npal1 , npal2 ;
00721          Three_D_View * qq3d ;
00722          XmStringGetLtoR( cbs->value , XmFONTLIST_DEFAULT_TAG , &text ) ;
00723          if( text != NULL ){
00724            if( THD_is_file(text) && !THD_is_directory(text) ){ /* read in file */
00725 
00726              if( im3d->vwid->func->inten_pbar->bigmode ){  /* 22 Oct 2003 */
00727                char *cmd = AFNI_suck_file( text ) ;
00728                ii = PBAR_define_bigmap(cmd); free(cmd);
00729                if( ii == 0 )
00730                  RWC_XtPopdown( im3d->vwid->file_dialog ) ;
00731                else
00732                  (void) MCW_popup_message( w ,
00733                                            "******************************\n"
00734                                            "** Can't use the colorscale **\n"
00735                                            "** file you selected!       **\n"
00736                                            "******************************"
00737                                          , MCW_USER_KILL | MCW_TIMER_KILL ) ;
00738              } else {
00739 
00740                npal1 = (GPT == NULL) ? 0 : PALTAB_NUM(GPT) ;  /* how many before */
00741 
00742                AFNI_process_setup( text , SETUP_LATER_MODE , im3d->dc ) ;
00743 
00744                npal2 = (GPT == NULL) ? 0 : PALTAB_NUM(GPT) ;  /* how many after */
00745 
00746                if( npal2 > npal1 ){                           /* if got some new ones */
00747                   for( ii=0 ; ii < MAX_CONTROLLERS ; ii++ ){
00748                      qq3d = GLOBAL_library.controllers[ii] ;
00749                      if( IM3D_VALID(qq3d) ){
00750                         refit_MCW_optmenu( qq3d->vwid->func->pbar_palette_av ,
00751                                            0 ,                     /* new minval */
00752                                            npal2-1 ,               /* new maxval */
00753                                            0 ,                     /* new inival */
00754                                            0 ,                     /* new decim? */
00755                                            AFNI_palette_label_CB , /* text routine */
00756                                            NULL                    /* text data */
00757                                           ) ;
00758 
00759                         /* 14 Jul 1998: whoops */
00760                         XtManageChild( qq3d->vwid->func->pbar_palette_av->wrowcol ) ;
00761 
00762                         /* 18 Sep 1998: set this palette to be the active one in the caller */
00763 
00764                         if( qq3d == im3d ){
00765                            AV_assign_ival( qq3d->vwid->func->pbar_palette_av , PALTAB_NUM(GPT)-1 ) ;
00766                            AFNI_palette_av_CB( qq3d->vwid->func->pbar_palette_av , im3d ) ;
00767                         }
00768                      }
00769                   }
00770                }
00771 
00772                dum = dump_PBAR_palette_table(0) ;
00773                (void) MCW_popup_message( im3d->vwid->func->options_label ,
00774                                          dum , MCW_USER_KILL | MCW_TIMER_KILL ) ;
00775                free(dum) ;
00776 
00777                RWC_XtPopdown( im3d->vwid->file_dialog ) ;  /* done with dialog */
00778              }
00779            } else {                                            /* bad filename */
00780               (void) MCW_popup_message( w ,
00781                                           "****************************\n"
00782                                           "** Can't open the palette **\n"
00783                                           "** file you selected!     **\n"
00784                                           "****************************"
00785                                       , MCW_USER_KILL | MCW_TIMER_KILL ) ;
00786               BEEPIT ;
00787            }
00788            XtFree(text) ;
00789          }
00790       }
00791       break ;
00792 
00793       case XmCR_HELP:
00794          (void) MCW_popup_message( w ,
00795                     "To read in a palette file, use the\n"
00796                     "Directories and Files selectors,\n"
00797                     "and the Filter entry and button,\n"
00798                     "to get the 'Selection' box correct;\n"
00799                     "that is, 'Selection' should be the\n"
00800                     "the name of the file you want to read.\n"
00801                     "Then press 'Set'.\n\n"
00802                     "N.B.: To use the new palette(s), you\n"
00803                     "      must use the 'Set Pal' chooser."
00804                  , MCW_USER_KILL ) ;
00805       break ;
00806    }
00807    EXRETURN ;
00808 }

void AFNI_finalize_saveim_CB Widget    wcaller,
XtPointer    cd,
MCW_choose_cbs   cbs
 

Definition at line 937 of file afni_setup.c.

References BEEPIT, MCW_choose_cbs::cval, ENTRY, free, AFNI_widget_set::func, getenv(), IM3D_OPEN, AFNI_function_widgets::inten_pbar, malloc, MCW_pbar_to_mri(), mcwCR_string, mri_free(), mri_write_pnm(), POPDOWN_string_chooser, MCW_choose_cbs::reason, THD_filename_ok(), and Three_D_View::vwid.

Referenced by AFNI_pbar_CB().

00938 {
00939    Three_D_View * im3d = (Three_D_View *) cd ;
00940    char * fname , * ptr ;
00941    int ll , nx=20 , ny=256 ;
00942    MRI_IMAGE * im ;
00943 
00944 ENTRY("AFNI_finalize_saveim_CB") ;
00945 
00946    if( ! IM3D_OPEN(im3d) || cbs->reason != mcwCR_string ||
00947        cbs->cval == NULL || (ll=strlen(cbs->cval)) == 0   ){BEEPIT; EXRETURN;}
00948 
00949    fname = (char *) malloc( sizeof(char) * (ll+8) ) ;
00950    strcpy( fname , cbs->cval ) ;
00951 
00952    if( ll > 240 || ! THD_filename_ok(fname) ){free(fname); BEEPIT; EXRETURN;}
00953 
00954                      ptr = strstr(fname,".ppm") ;
00955    if( ptr == NULL ) ptr = strstr(fname,".pnm") ;
00956    if( ptr == NULL ) ptr = strstr(fname,".jpg") ;
00957    if( ptr == NULL ) strcat(fname,".ppm") ;
00958 
00959    fprintf(stderr,"Writing palette image to %s\n",fname) ;
00960 
00961    ptr = getenv( "AFNI_PBAR_IMXY" );
00962    if( ptr != NULL ){
00963       ll = sscanf( ptr , "%dx%d" , &nx , &ny ) ;
00964       if( ll < 2 || nx < 1 || ny < 32 ){ nx=20; ny=256; }
00965    }
00966 
00967    im = MCW_pbar_to_mri( im3d->vwid->func->inten_pbar , nx,ny ) ;
00968    mri_write_pnm( fname , im ) ;
00969 
00970    POPDOWN_string_chooser; mri_free(im); free(fname); EXRETURN;
00971 }

void AFNI_finalize_write_palette_CB Widget    wcaller,
XtPointer    cd,
MCW_choose_cbs   cbs
 

Definition at line 848 of file afni_setup.c.

References rgbyte::b, BEEPIT, MCW_pbar::bigcolor, MCW_pbar::bigmode, MCW_pbar::bigname, MCW_choose_cbs::cval, Three_D_View::dc, ENTRY, free, AFNI_widget_set::func, rgbyte::g, IM3D_OPEN, AFNI_function_widgets::inten_pbar, MCW_DCOV::label_ov, malloc, MCW_popup_message(), MCW_TIMER_KILL, MCW_USER_KILL, mcwCR_string, MCW_pbar::mode, MCW_DCOV::name_ov, NPANE_BIG, NPANE_MAX, MCW_pbar::num_panes, AFNI_function_widgets::options_label, MCW_pbar::ov_index, MCW_DC::ovc, POPDOWN_string_chooser, MCW_pbar::pval, rgbyte::r, MCW_choose_cbs::reason, THD_filename_ok(), and Three_D_View::vwid.

Referenced by AFNI_pbar_CB().

00849 {
00850    Three_D_View * im3d = (Three_D_View *) cd ;
00851    int ll , ii , jj ;
00852    char * fname , * ptr ;
00853    FILE * fp ;
00854    MCW_pbar * pbar ;
00855    int jm , npane , novu , ovu[NPANE_MAX] ;
00856    int * ovin ;
00857    float * pval ;
00858 
00859 ENTRY("AFNI_finalize_write_palette_CB") ;
00860 
00861    if( ! IM3D_OPEN(im3d) || cbs->reason != mcwCR_string ||
00862        cbs->cval == NULL || (ll=strlen(cbs->cval)) == 0   ){BEEPIT; EXRETURN;}
00863 
00864    fname = (char *) malloc( sizeof(char) * (ll+8) ) ;
00865    strcpy( fname , cbs->cval ) ;
00866 
00867    if( ll > 240 || ! THD_filename_ok(fname) ){free(fname); BEEPIT; EXRETURN;}
00868 
00869    ptr = strstr(fname,".pal") ;
00870    if( ptr == NULL || ptr[4] != '0' ){ strcat(fname,".pal"); ll += 4; }
00871    fp = fopen( fname , "a" ) ;
00872    if( fp == NULL ){
00873       char buf[512] ;
00874       sprintf(buf,"Can't open file\n %s\nfor writing!",fname) ;
00875       (void) MCW_popup_message( im3d->vwid->func->options_label ,
00876                                 buf , MCW_USER_KILL | MCW_TIMER_KILL ) ;
00877       BEEPIT ; free(fname) ; EXRETURN ;
00878    } else {
00879       char buf[512] ;
00880       sprintf(buf,"\nWriting current palette to file\n %s\n",fname) ;
00881       (void) MCW_popup_message( im3d->vwid->func->options_label ,
00882                                 buf , MCW_USER_KILL | MCW_TIMER_KILL ) ;
00883    }
00884 
00885    pbar  = im3d->vwid->func->inten_pbar ;
00886    npane = pbar->num_panes ;
00887    jm    = pbar->mode ;
00888    ovin  = pbar->ov_index ;
00889    pval  = pbar->pval ;
00890 
00891    /* 22 Oct 2003: Colorscale? */
00892 
00893    if( pbar->bigmode ){
00894      fprintf(fp,"%s\n",pbar->bigname) ;
00895      for( ii=0 ; ii < NPANE_BIG ; ii++ )
00896        fprintf(fp,"#%02x%02x%02x\n",
00897                (unsigned int)pbar->bigcolor[ii].r ,
00898                (unsigned int)pbar->bigcolor[ii].g ,
00899                (unsigned int)pbar->bigcolor[ii].b  ) ;
00900    } else {
00901 
00902      /* make list of all discrete colors used, pruning redundancies */
00903 
00904      novu = 1 ; ovu[0] = ovin[0] ;
00905      for( ii=1 ; ii < npane ; ii++ ){        /* check each pane */
00906        for( jj=0 ; jj < novu ; jj++ )       /* for match with current list */
00907          if( ovin[ii] == ovu[jj] ) break ;
00908 
00909        if( jj == novu )                     /* didn't find a match */
00910          ovu[novu++] = ovin[ii] ;
00911      }
00912 
00913      /* write colors to file */
00914 
00915      fprintf( fp , "\n***COLORS\n" ) ;
00916      for( ii=0 ; ii < novu ; ii++ ){
00917        if( ovu[ii] > 0 )                                   /* don't write 'none' */
00918          fprintf( fp , "  %s = %s\n" ,
00919                   im3d->dc->ovc->label_ov[ovu[ii]] ,
00920                   im3d->dc->ovc->name_ov[ovu[ii]]   ) ;
00921      }
00922 
00923      fname[ll-4] = '\0' ;
00924      fprintf( fp , "\n***PALETTES %s [%d%s\n" ,
00925               fname , npane , (jm==0) ? "]" : "+]" ) ;
00926 
00927      for( ii=0 ; ii < npane ; ii++ )
00928        fprintf( fp , "  %f -> %s\n" ,
00929                 pval[ii] , im3d->dc->ovc->label_ov[ovin[ii]] ) ;
00930    }
00931 
00932    POPDOWN_string_chooser; fclose(fp); free(fname); EXRETURN;
00933 }

void AFNI_palette_av_CB MCW_arrowval   av,
XtPointer    cd
 

Definition at line 680 of file afni_setup.c.

References AFNI_redisplay_func(), ENTRY, AFNI_widget_set::func, AFNI_view_info::func_visible, GPT, IM3D_VALID, AFNI_function_widgets::inten_pbar, MCW_arrowval::ival, load_PBAR_palette_array(), PALTAB_ARR, PALTAB_NUM, Three_D_View::vinfo, and Three_D_View::vwid.

Referenced by AFNI_finalize_read_palette_CB().

00681 {
00682    Three_D_View * im3d = (Three_D_View *) cd ;
00683 
00684 ENTRY("AFNI_palette_av_CB") ;
00685 
00686    if( ! IM3D_VALID(im3d) || GPT == NULL ) EXRETURN ;
00687    if( av->ival < 0 || av->ival >= PALTAB_NUM(GPT) ) EXRETURN ;
00688 
00689    load_PBAR_palette_array( im3d->vwid->func->inten_pbar ,
00690                             PALTAB_ARR(GPT,av->ival) , 1  ) ;
00691 
00692    if( im3d->vinfo->func_visible )
00693       AFNI_redisplay_func( im3d ) ;
00694 
00695    EXRETURN ;
00696 }

char* AFNI_palette_label_CB MCW_arrowval   av,
XtPointer    cd
 

Definition at line 527 of file afni_setup.c.

References GPT, MCW_arrowval::ival, PALTAB_ARR_LABEL, and PALTAB_NUM.

Referenced by AFNI_finalize_read_palette_CB().

00528 {
00529    static char blab[32] ;
00530 
00531    if( av->ival >= 0 && av->ival < PALTAB_NUM(GPT) )
00532       sprintf(blab,"%-.14s",PALTAB_ARR_LABEL(GPT,av->ival)) ;
00533    else
00534       strcpy(blab,"???") ;
00535 
00536    return blab ;
00537 }

void AFNI_palette_tran_CB MCW_arrowval   av,
XtPointer    cd
 

Definition at line 975 of file afni_setup.c.

References AFNI_redisplay_func(), ENTRY, AFNI_widget_set::func, MCW_function_list::func_init, AFNI_view_info::func_visible, MCW_function_list::funcs, GLOBAL_library, IM3D_VALID, MCW_arrowval::ival, AFNI_function_widgets::pbar_transform0D_av, AFNI_function_widgets::pbar_transform0D_func, AFNI_function_widgets::pbar_transform0D_index, AFNI_function_widgets::pbar_transform2D_av, AFNI_function_widgets::pbar_transform2D_func, AFNI_function_widgets::pbar_transform2D_index, AFNI_library_type::registered_0D, AFNI_library_type::registered_2D, Three_D_View::vinfo, and Three_D_View::vwid.

00976 {
00977    Three_D_View * im3d = (Three_D_View *) cd ;
00978 
00979 ENTRY("AFNI_palette_tran_CB") ;
00980 
00981    if( !IM3D_VALID(im3d) ) EXRETURN ;
00982 
00983    if( av == im3d->vwid->func->pbar_transform0D_av ){         /* 15 Jun 2000 */
00984 
00985       im3d->vwid->func->pbar_transform0D_index = av->ival ;
00986       if( av->ival == 0 )
00987          im3d->vwid->func->pbar_transform0D_func = NULL ;
00988       else {
00989          im3d->vwid->func->pbar_transform0D_func =
00990             GLOBAL_library.registered_0D.funcs[av->ival-1];
00991          if( GLOBAL_library.registered_0D.func_init[av->ival-1] != NULL )
00992            GLOBAL_library.registered_0D.func_init[av->ival-1]() ;
00993       }
00994 
00995    } else if( av == im3d->vwid->func->pbar_transform2D_av ){  /* 16 Jun 2000 */
00996 
00997       im3d->vwid->func->pbar_transform2D_index = av->ival ;
00998       if( av->ival == 0 )
00999          im3d->vwid->func->pbar_transform2D_func = NULL ;
01000       else{
01001          im3d->vwid->func->pbar_transform2D_func =
01002             GLOBAL_library.registered_2D.funcs[av->ival-1];
01003          if( GLOBAL_library.registered_2D.func_init[av->ival-1] != NULL )
01004            GLOBAL_library.registered_2D.func_init[av->ival-1]() ;
01005       }
01006    }
01007 
01008    if( im3d->vinfo->func_visible )
01009       AFNI_redisplay_func( im3d ) ;
01010 
01011    EXRETURN ;
01012 }

void AFNI_pbar_CB Widget    w,
XtPointer    cd,
XtPointer    cbs
 

Definition at line 571 of file afni_setup.c.

References AFNI_finalize_read_palette_CB(), AFNI_finalize_saveim_CB(), AFNI_finalize_write_palette_CB(), AFNI_make_file_dialog(), AFNI_misc_CB(), AFNI_set_pbar_top_CB(), alter_MCW_pbar(), BEEPIT, MCW_pbar::bigmode, AFNI_widget_set::dmode, dump_PBAR_palette_table(), ENTRY, AFNI_widget_set::file_cb, AFNI_widget_set::file_cd, AFNI_widget_set::file_dialog, AFNI_widget_set::file_sbox, FIX_SCALE_SIZE, free, AFNI_widget_set::func, HIDE_SCALE, IM3D_OPEN, AFNI_function_widgets::inten_pbar, MCW_choose_integer(), MCW_choose_string(), AFNI_datamode_widgets::misc_environ_pb, MCW_pbar::mode, new_MCW_textwin(), NPANE_MAX, MCW_pbar::num_panes, AFNI_function_widgets::options_label, AFNI_function_widgets::pbar_environment_pb, AFNI_function_widgets::pbar_equalize_pb, AFNI_function_widgets::pbar_readin_pb, AFNI_function_widgets::pbar_saveim_pb, AFNI_function_widgets::pbar_settop_pb, AFNI_function_widgets::pbar_showtable_pb, AFNI_function_widgets::pbar_writeout_pb, pmax, pmin, MCW_pbar::pval_save, RWC_visibilize_widget(), TEXT_READONLY, and Three_D_View::vwid.

00572 {
00573    Three_D_View *im3d = (Three_D_View *) cd ;
00574    MCW_pbar *pbar ;
00575    int npane , jm , ii ;
00576    double pmax , pmin ;
00577    float pval[NPANE_MAX+1] ;
00578 
00579 ENTRY("AFNI_pbar_CB") ;
00580 
00581    if( ! IM3D_OPEN(im3d) ) EXRETURN ;
00582 
00583    pbar  = im3d->vwid->func->inten_pbar ;
00584    npane = pbar->num_panes ;
00585    jm    = pbar->mode ;
00586    pmax  = pbar->pval_save[npane][0][jm] ;
00587    pmin  = pbar->pval_save[npane][npane][jm] ;
00588 
00589    /*--- Equalize spacings ---*/
00590 
00591    if( w == im3d->vwid->func->pbar_equalize_pb ){
00592 
00593       if( pbar->bigmode ){ BEEPIT; EXRETURN; } /* 30 Jan 2003 */
00594 
00595       for( ii=0 ; ii <= npane ; ii++ )
00596          pval[ii] = pmax - ii * (pmax-pmin)/npane ;
00597 
00598       HIDE_SCALE(im3d) ;
00599       alter_MCW_pbar( pbar , 0 , pval ) ;
00600       FIX_SCALE_SIZE(im3d) ;
00601    }
00602 
00603    /*--- Set top value ---*/
00604 
00605    else if( w == im3d->vwid->func->pbar_settop_pb ){
00606       MCW_choose_integer( im3d->vwid->func->options_label ,
00607                           "Pbar Top" , 0 , 99999 , 1 ,
00608                           AFNI_set_pbar_top_CB , cd   ) ;
00609    }
00610 
00611    /*--- Read in a palette file ---*/
00612 
00613    else if( w == im3d->vwid->func->pbar_readin_pb ){
00614       XmString xstr ;
00615 
00616       AFNI_make_file_dialog( im3d ) ;
00617       XtAddCallback( im3d->vwid->file_sbox , XmNokCallback ,
00618                      AFNI_finalize_read_palette_CB , cd ) ;
00619       XtAddCallback( im3d->vwid->file_sbox , XmNcancelCallback ,
00620                      AFNI_finalize_read_palette_CB , cd ) ;
00621       XtAddCallback( im3d->vwid->file_sbox , XmNhelpCallback ,
00622                      AFNI_finalize_read_palette_CB , cd ) ;
00623       im3d->vwid->file_cb = AFNI_finalize_read_palette_CB ;
00624       im3d->vwid->file_cd = cd ;
00625       XtVaSetValues( im3d->vwid->file_dialog,
00626                         XmNtitle,
00627                         (pbar->bigmode) ? "AFNI: Read colorscale"
00628                                         : "AFNI: Read Palette" ,
00629                      NULL ) ;
00630 
00631       xstr = XmStringCreateLtoR( "*.pal"  , XmFONTLIST_DEFAULT_TAG ) ;
00632       XtVaSetValues( im3d->vwid->file_sbox , XmNpattern , xstr , NULL ) ;
00633       XmStringFree(xstr) ;
00634 
00635       XtPopup( im3d->vwid->file_dialog , XtGrabNone ) ;
00636       RWC_visibilize_widget( im3d->vwid->file_dialog ) ; /* 09 Nov 1999 */
00637    }
00638 
00639    /*--- Write out a palette file ---*/
00640 
00641    else if( w == im3d->vwid->func->pbar_writeout_pb ){
00642       MCW_choose_string( im3d->vwid->func->options_label ,
00643                          (pbar->bigmode) ? "Colorscale Name" : "Palette Name" ,
00644                          NULL , AFNI_finalize_write_palette_CB , cd ) ;
00645    }
00646 
00647    /*--- Display the palette table ---*/
00648 
00649    else if( w == im3d->vwid->func->pbar_showtable_pb ){
00650       char * dum = dump_PBAR_palette_table(1) ;
00651       new_MCW_textwin( im3d->vwid->func->options_label, dum, TEXT_READONLY ) ;
00652       free(dum) ;
00653    }
00654 
00655    /*--- Save pbar into image file ---*/
00656 
00657    else if( w == im3d->vwid->func->pbar_saveim_pb ){
00658       MCW_choose_string( im3d->vwid->func->options_label ,
00659                          "PPM file prefix" , NULL ,
00660                          AFNI_finalize_saveim_CB , cd ) ;
00661    }
00662 
00663    /*---- 10 Feb 2004: start the Edit Environment pseudo-plugin ----*/
00664 
00665    else if( w == im3d->vwid->func->pbar_environment_pb &&
00666             w != NULL                                    ){
00667 
00668      AFNI_misc_CB( im3d->vwid->dmode->misc_environ_pb ,
00669                    (XtPointer) im3d , (XtPointer) NULL ) ;
00670    }
00671 
00672 
00673    /*** done ***/
00674 
00675    EXRETURN ;
00676 }

void AFNI_pbar_EV Widget    w,
XtPointer    cd,
XEvent *    ev,
Boolean *    continue_to_dispatch
 

Definition at line 543 of file afni_setup.c.

References AFNI_widget_set::butx, AFNI_widget_set::buty, ENTRY, ev, event, AFNI_widget_set::func, IM3D_OPEN, AFNI_function_widgets::pbar_menu, and Three_D_View::vwid.

00545 {
00546    Three_D_View *im3d = (Three_D_View *) cd ;
00547 
00548 ENTRY("AFNI_pbar_EV") ;
00549 
00550    if( ! IM3D_OPEN(im3d) ) EXRETURN ;
00551 
00552    switch( ev->type ){
00553       case ButtonPress:{
00554          XButtonEvent *event = (XButtonEvent *) ev ;
00555          im3d->vwid->butx = event->x_root ;  /* 17 May 2005 */
00556          im3d->vwid->buty = event->y_root ;
00557          event->button    = Button3 ;                            /* fakeout */
00558          XmMenuPosition( im3d->vwid->func->pbar_menu , event ) ; /* where */
00559          XtManageChild ( im3d->vwid->func->pbar_menu ) ;         /* popup */
00560       }
00561       break ;
00562    }
00563 
00564    EXRETURN ;
00565 }

void AFNI_process_setup char *    fname,
int    mode,
MCW_DC   dc
 

Definition at line 58 of file afni_setup.c.

References ADDTO_PALTAB, AFNI_suck_file(), check_PBAR_palette(), PBAR_palette::col, DC_add_overlay_color(), DC_find_overlay_color(), ENTRY, free, GETEQN, GETSTR, GPT, INIT_ncolovr, INIT_PALARR, INIT_PALTAB, ISTARRED, label_in_PALTAB(), left, malloc, MAX_NCOLOVR, PBAR_palette::mode, myXtFree, PBAR_palette::npane, NPANE_MAX, nr, NSBUF, MCW_DC::ovc, OVC_mostest(), PAL_FIGNORE, PAL_IIGNORE, PALTAB_ARR, PALTAB_NUM, PBAR_palette_array::ppos, PBAR_palette_array::psgn, right, SETUP_ENVIRON_MODE, SETUP_INIT_MODE, SETUP_LATER_MODE, STATUS, strtod(), THD_filename_ok(), THD_filename_pure(), and PBAR_palette::val.

Referenced by AFNI_finalize_read_palette_CB(), and main().

00059 {
00060    int    nbuf , nused , ii ;
00061    char * fbuf , * fptr ;
00062    char str[NSBUF] , left[NSBUF] , middle[NSBUF] , right[NSBUF] ;
00063 
00064 ENTRY("AFNI_process_setup") ;
00065 
00066    fbuf = AFNI_suck_file( fname ) ; if( fbuf == NULL ) EXRETURN ;
00067    nbuf = strlen(fbuf) ;            if( nbuf == 0    ) EXRETURN ;
00068 
00069    fptr = fbuf ; nused = 0 ;
00070 
00071    /** scan for section strings, which start with "***" **/
00072 
00073    str[0] = '\0' ;  /* initialize string */
00074 
00075 if(PRINT_TRACING)
00076 { char str[256] ;
00077   sprintf(str,"Reading AFNI setup file = %s (%d bytes)",fname,nbuf) ;
00078   STATUS(str);}
00079 
00080    while( nused < nbuf ){
00081 
00082       /**----------------------------------------**/
00083       /**-- skip ahead to next section keyword --**/
00084 
00085       SkipSection: while( ! ISTARRED(str) ){ GETSTR; }
00086 
00087       /*- 04 Jun 1999 -*/
00088 
00089       if( mode == SETUP_ENVIRON_MODE && strcmp(str,"***ENVIRONMENT") != 0 ){
00090          GETSTR ;
00091          goto SkipSection ;
00092       }
00093 
00094       /**--------------------**/
00095       /**-- COLORS section --**/
00096 
00097       if( strcmp(str,"***COLORS") == 0 ){
00098          char label[NSBUF] , defn[NSBUF] ;
00099 
00100 STATUS("enter ***COLORS") ;
00101 
00102          while(1){                          /* loop, looking for 'label = color' */
00103             GETEQN ;
00104 
00105 if(PRINT_TRACING)
00106 { char str[256] ;
00107   sprintf(str,"GETEQN: %s %s %s",left,middle,right) ; STATUS(str);}
00108 
00109             /* don't allow 'none' to be redefined! */
00110 
00111             if( strcmp(left,"none")==0 || strcmp(right,"none")==0 ) continue ;
00112             if( !THD_filename_pure(left) ) continue ;
00113 
00114             if( mode == SETUP_INIT_MODE ){
00115                if( INIT_ncolovr < MAX_NCOLOVR ){
00116                   ii = INIT_ncolovr++ ;
00117                   INIT_labovr[ii] = XtNewString(left) ;
00118                   INIT_colovr[ii] = XtNewString(right) ;
00119 
00120 if(PRINT_TRACING)
00121 { char str[256] ;
00122   sprintf(str,"setup into #%d",ii) ; STATUS(str);}
00123 
00124                } else {
00125                   fprintf(stderr,"\nIn setup file %s, color table overflow!\n",fname);
00126                   goto SkipSection ;
00127                }
00128             } else if( mode == SETUP_LATER_MODE ){
00129                ii = DC_add_overlay_color( dc , right , left ) ;
00130 
00131 if(PRINT_TRACING)
00132 { char str[256] ;
00133   sprintf(str,"'new' color index returned as #%d",ii) ; STATUS(str);}
00134 
00135                if( ii < 0 )
00136                   fprintf(stderr,"\nIn setup file %s, unknown color %s\n",fname,right);
00137                else
00138                   OVC_mostest( dc->ovc ) ;
00139             }
00140          }
00141          continue ;  /* skip to end of outer while loop */
00142       } /* end of COLORS */
00143 
00144       /**----------------------**/
00145       /**-- PALETTES section --**/
00146 
00147       if( strcmp(str,"***PALETTES") == 0 ){  /* loop, looking for palettes */
00148          char label[NSBUF] = "NoThing" , ccc , * cpt ;
00149          PBAR_palette_array * ppar=NULL ;
00150          PBAR_palette ** ppp ;
00151          PBAR_palette  * ppnew ;
00152          int npane , pmode , icol=0 , jj ;
00153          float val ;
00154 
00155 STATUS("enter ***PALETTES") ;
00156 
00157          if( GPT == NULL ){               /* 1st time in --> create palettry */
00158 STATUS("create initial palettes") ;
00159             INIT_PALTAB(GPT) ;
00160             INIT_PALARR(ppar,"NoThing") ;
00161             ADDTO_PALTAB(GPT,ppar) ;
00162          }
00163 
00164          /* loop, looking for palettes */
00165 
00166          while(1){
00167             GETSTR ; if( ISTARRED(str) ) goto SkipSection ;
00168             if( fptr-fbuf >= nbuf ){ free(fbuf) ; EXRETURN ; }
00169 
00170             if( str[0] != '[' ){                     /* found a palette label */
00171                strcpy(label,str) ;
00172                if( !THD_filename_ok(label) ){
00173                   fprintf(stderr,"\nIn setup file %s, bad palette label: %s.\n",
00174                           fname,label) ;
00175                   free(fbuf) ; EXRETURN ;
00176                }
00177 
00178 if(PRINT_TRACING)
00179 { char str[256] ;
00180   sprintf(str,"found palette label=%s. [len=%d label[0]=%d]",
00181           label,(int)strlen(label),(int)label[0]); STATUS(str);
00182   sprintf(str,"nbuf=%d fptr-fbuf=%d",nbuf,fptr-fbuf); STATUS(str);}
00183 
00184                ii = label_in_PALTAB( GPT , label ) ; /* an old one? */
00185                if( ii < 0 ){
00186 STATUS("making a new palette array") ;
00187                   INIT_PALARR(ppar,label) ;          /* make a new palette array */
00188                   ADDTO_PALTAB(GPT,ppar) ;
00189                } else {
00190 
00191 if(PRINT_TRACING)
00192 { char str[256] ;
00193   sprintf(str,"matches old palette array #%d",ii) ; STATUS(str);}
00194 
00195                   ppar = PALTAB_ARR(GPT,ii) ;        /* retrieve old palette array */
00196                }
00197                GETSTR ; if( ISTARRED(str) ) goto SkipSection ;
00198             }
00199 
00200 if(PRINT_TRACING)
00201 { char str[256] ;
00202   sprintf(str,"GPT now has %d arrays",PALTAB_NUM(GPT)) ; STATUS(str);}
00203 
00204             if( str[0] != '[' ){                    /* bad news! */
00205                fprintf(stderr,"\nIn setup file %s, expected palette '[n]' here: %s\n",
00206                               fname , str ) ;
00207                break ;
00208             }
00209 
00210             /* decide how big the new palette is to be, and what mode  */
00211             ii = sscanf( str , "[%d%c" , &npane , &ccc ) ;
00212             if( ii < 2 ){
00213                fprintf(stderr,"\nIn setup file %s, can't interpret palette %s\n",
00214                               fname , str ) ;
00215                break ;
00216             } else if( npane < NPANE_MIN || npane > NPANE_MAX ){
00217                fprintf(stderr,"\nIn setup file %s, illegal palette count %s\n",
00218                               fname , str ) ;
00219                break ;
00220             }
00221 
00222             pmode = (ccc == '+') ? 1 : 0 ;              /* pbar mode */
00223             ppp   = (pmode==0) ? (ppar->psgn + npane)   /* pointer to pointer */
00224                                : (ppar->ppos + npane) ; /* to existing palette */
00225 
00226 if(PRINT_TRACING)
00227 { char str[256] ;
00228   sprintf(str,"palette definition: npane=%d pmode=%d",npane,pmode) ;
00229   STATUS(str); }
00230 
00231             ppnew = XtNew(PBAR_palette) ;               /* make a new palette */
00232             ppnew->npane = npane ;
00233             ppnew->mode  = pmode ;
00234             for( ii=0 ; ii < npane ; ii++ ){
00235                ppnew->val[ii] = PAL_FIGNORE ; ppnew->col[ii] = PAL_IIGNORE ;
00236             }
00237 
00238             /* at this point, now loop to read parameters for new palette */
00239 
00240             for( ii=0 ; ii < npane ; ii++ ){
00241                GETEQN ;
00242 
00243 if(PRINT_TRACING)
00244 { char str[256] ;
00245   sprintf(str,"GETEQN: %s %s %s",left,middle,right) ; STATUS(str);}
00246 
00247                val = strtod(left,&cpt) ;
00248                if( val == 0.0 && *cpt != '\0' ) val = PAL_FIGNORE ;
00249 
00250                if( mode == SETUP_INIT_MODE ){
00251                  if( strcmp(right,"none") == 0 ){
00252                     icol = 0 ;
00253                  } else {
00254                     for( jj=0 ; jj < INIT_ncolovr ; jj++ )
00255                        if( strcmp(right,INIT_labovr[jj]) == 0 ) break ;
00256                     icol = (jj < INIT_ncolovr) ? jj+1 : PAL_IIGNORE ;
00257                  }
00258                } else if( mode == SETUP_LATER_MODE ){
00259                   icol = DC_find_overlay_color( dc , right ) ;
00260                   if( icol < 0 ) icol = PAL_IIGNORE ;
00261 
00262 if(PRINT_TRACING)
00263 { char str[256] ;
00264   sprintf(str,"  DC_find_overlay_color(%s) returns %d\n",right,icol) ;
00265   STATUS(str) ; }
00266 
00267                }
00268                ppnew->val[ii] = val ; ppnew->col[ii] = icol ;
00269 
00270 if(PRINT_TRACING)
00271 { char str[256] ;
00272   sprintf(str,"new palette entry #%d: val=%f col=%d",ii,val,icol) ;
00273   STATUS(str);}
00274 
00275             }
00276 
00277             ii = check_PBAR_palette( ppnew ) ;
00278             if( ii < 0 ){
00279                fprintf(stderr,"\nIn setup file %s, palette '%s [%d%s' is illegal\n",
00280                        fname,label,npane, (pmode==0)?"]":"+]" ) ;
00281                myXtFree(ppnew) ;
00282             } else {
00283                myXtFree(*ppp) ;
00284                *ppp = ppnew ;
00285 
00286 STATUS("stored new palette") ;
00287             }
00288          }
00289 
00290          continue ;  /* to end of outer while */
00291       } /* end of PALETTES */
00292 
00293       /**---------------------------------------**/
00294       /**-- ENVIRONMENT section [04 Jun 1999] --**/
00295 
00296       if( strcmp(str,"***ENVIRONMENT") == 0 ){  /* loop, looking for environment settings */
00297          char *enveqn ; int nl , nr ;
00298 
00299          if( mode != SETUP_ENVIRON_MODE ){ GETSTR ; goto SkipSection ; }
00300 
00301 STATUS("enter ***ENVIRONMENT") ;
00302 
00303          while(1){                          /* loop, looking for 'name = value' */
00304             GETEQN ;
00305 
00306 if(PRINT_TRACING)
00307 { char str[256] ;
00308   sprintf(str,"GETEQN: %s %s %s",left,middle,right) ; STATUS(str);}
00309 
00310             if( !THD_filename_pure(left) ) continue ;
00311 
00312             nl = strlen(left) ; nr = strlen(right) ;
00313             enveqn = (char *) malloc(nl+nr+4) ;
00314             strcpy(enveqn,left) ; strcat(enveqn,"=") ; strcat(enveqn,right) ;
00315             putenv(enveqn) ;
00316          }
00317 
00318          continue ;  /* to end of outer while */
00319       } /* end of ENVIRONMENT */
00320 
00321       /** END **/
00322 
00323       if( strcmp(str,"***END") == 0 ) break ;  /* exit main loop */
00324 
00325       /** unknown section **/
00326 
00327 #if 0
00328       fprintf(stderr,"\nIn setup file %s, unknown section: %s\n",
00329                      fname , str ) ;
00330       break ;                                 /* exit main loop */
00331 #else
00332       GETSTR ; goto SkipSection ;             /* find another section */
00333 #endif
00334 
00335    }  /* end of while loop */
00336 
00337    free(fbuf) ; EXRETURN ;
00338 }

void AFNI_set_pbar_top_CB Widget    wcaller,
XtPointer    cd,
MCW_choose_cbs   cbs
 

try to read a new palette *

Definition at line 812 of file afni_setup.c.

References AFNI_inten_pbar_CB(), alter_MCW_pbar(), BEEPIT, MCW_pbar::bigmode, MCW_pbar::bigset, ENTRY, FIX_SCALE_SIZE, AFNI_widget_set::func, MCW_choose_cbs::fval, HIDE_SCALE, IM3D_OPEN, AFNI_function_widgets::inten_pbar, MCW_pbar::mode, NORMAL_cursorize, NPANE_MAX, MCW_pbar::num_panes, MCW_pbar::panew, PBAR_set_bigmode(), pmax, pmin, POPUP_cursorize, MCW_pbar::pval, and Three_D_View::vwid.

Referenced by AFNI_pbar_CB().

00813 {
00814    Three_D_View * im3d = (Three_D_View *) cd ;
00815    MCW_pbar * pbar ;
00816    float pval[NPANE_MAX+1] ;
00817    double pmin,pmax , fac ;
00818    int ii ;
00819 
00820 ENTRY("AFNI_set_pbar_top_CB") ;
00821 
00822    if( ! IM3D_OPEN(im3d) ) EXRETURN ;
00823 
00824    pmax  = cbs->fval ; if( pmax <= 0.0 ){ BEEPIT; EXRETURN; }
00825    pbar  = im3d->vwid->func->inten_pbar ;
00826 
00827    HIDE_SCALE(im3d) ;
00828    if( pbar->bigmode ){              /* 30 Jan 2003 */
00829      pbar->bigset = 0 ;
00830      pmin = (pbar->mode) ? 0.0 : -pmax ;
00831      PBAR_set_bigmode( pbar , 1 , pmin,pmax ) ;
00832      AFNI_inten_pbar_CB( pbar , im3d , 0 ) ;
00833      POPUP_cursorize( pbar->panew ) ;  /* 08 Apr 2005 */
00834    } else {
00835      fac = pmax / pbar->pval[0] ;
00836      for( ii=0 ; ii <= pbar->num_panes ; ii++ )
00837        pval[ii] = fac * pbar->pval[ii] ;
00838      alter_MCW_pbar( pbar , 0 , pval ) ;
00839      NORMAL_cursorize( pbar->panew ) ;  /* 08 Apr 2005 */
00840    }
00841    FIX_SCALE_SIZE(im3d) ;
00842 
00843    EXRETURN ;
00844 }

int check_PBAR_palette PBAR_palette   pp
 

unknown section *

Definition at line 342 of file afni_setup.c.

References ENTRY, PBAR_palette::mode, PBAR_palette::npane, NPANE_MAX, NPANE_MIN, PAL_FIGNORE, PANE_MAXMODE, RETURN, and PBAR_palette::val.

Referenced by AFNI_process_setup().

00343 {
00344    int ii , nn ;
00345 
00346 ENTRY("check_PBAR_palette") ;
00347 
00348    if( pp == NULL ) RETURN(-1) ;
00349    if( pp->npane < NPANE_MIN || pp->npane >  NPANE_MAX    ) RETURN(-1) ;
00350    if( pp->mode  < 0         || pp->mode  >= PANE_MAXMODE ) RETURN(-1) ;
00351 
00352    /** val must be all numbers or all ignores -- nothing mixed **/
00353 
00354    nn = 0 ;
00355    for( ii=0 ; ii < pp->npane ; ii++ )
00356       if( pp->val[ii] == PAL_FIGNORE ) nn++ ;
00357    if( nn > 0 && nn != pp->npane ) RETURN(-1) ;
00358 
00359    /** if all numbers, must be ordered **/
00360 
00361    if( nn == 0 ){
00362       if( pp->val[0] <= 0.0 ) RETURN(-1) ;  /* 1st must be positive */
00363       for( ii=1 ; ii < pp->npane ; ii++ )
00364          if( pp->val[ii] >= pp->val[ii-1] ) RETURN(-1) ;  /* disordered? */
00365 
00366       if( pp->mode == 1 && pp->val[pp->npane-1] < 0.0 ) RETURN(-1) ;
00367    }
00368 
00369    RETURN(1) ;
00370 }

char* dump_PBAR_palette_table int    verb
 

if all numbers, must be ordered *

Definition at line 373 of file afni_setup.c.

References PBAR_palette::col, AFNI_library_type::dc, ENTRY, GLOBAL_library, GPT, MCW_DCOV::label_ov, malloc, MCW_DCOV::name_ov, MCW_DCOV::ncol_ov, NPANE_MAX, NPANE_MIN, MCW_DC::ovc, PAL_FIGNORE, PALTAB_ARR, PALTAB_ARR_LABEL, PALTAB_ARR_PPOS, PALTAB_ARR_PSGN, PALTAB_NUM, realloc, RETURN, s2, and PBAR_palette::val.

Referenced by AFNI_finalize_read_palette_CB(), AFNI_pbar_CB(), and main().

00374 {
00375    int ii , jj , nn , nsss,nuuu , nbuf , kk ;
00376    char * sss ;
00377    static char buf[2048] ;
00378    char s1[32] , s2[32] ;
00379    PBAR_palette * pp ;
00380    MCW_DC * dc = GLOBAL_library.dc ;
00381 
00382 ENTRY("dump_PBAR_palette_table") ;
00383 
00384    nsss = 256 ; sss = (char *) malloc(sizeof(char) * nsss) ;
00385    sss[0] = '\0' ; nuuu = 0 ;
00386 
00387    if( verb ){
00388       sprintf(sss,"Overlay Color Table: \n") ; nuuu = strlen(sss) ;
00389       for( kk=1 ; kk < dc->ovc->ncol_ov ; kk++ ){
00390          sprintf(buf,"  %s = %s\n" , dc->ovc->label_ov[kk] , dc->ovc->name_ov[kk] ) ;
00391          nbuf = strlen(buf) ;
00392          if( nbuf+nuuu+2 > nsss ){
00393             nsss = nbuf+nuuu+128 ;
00394             sss = (char *) realloc( sss , sizeof(char) * nsss ) ;
00395          }
00396          strcat(sss,buf) ; nuuu = strlen(sss) ;
00397       }
00398    }
00399 
00400    if( GPT == NULL || PALTAB_NUM(GPT) == 0 ){
00401       sprintf(buf,"\nPalette Table: *** EMPTY ***\n") ;
00402       nbuf = strlen(buf) ;
00403       if( nbuf+nuuu+2 > nsss ){
00404          nsss = nbuf+nuuu+128 ;
00405          sss = (char *) realloc( sss , sizeof(char) * nsss ) ;
00406       }
00407       strcat(sss,buf) ; nuuu = strlen(sss) ;
00408       RETURN(sss) ;
00409    }
00410 
00411    sprintf(buf,"\nPalette Table:\n") ;
00412    nbuf = strlen(buf) ;
00413    if( nbuf+nuuu+2 > nsss ){
00414       nsss = nbuf+nuuu+128 ;
00415       sss = (char *) realloc( sss , sizeof(char) * nsss ) ;
00416    }
00417    strcat(sss,buf) ; nuuu = strlen(sss) ;
00418 
00419    for( ii=0 ; ii < PALTAB_NUM(GPT) ; ii++ ){
00420       if( PALTAB_ARR(GPT,ii) == NULL ){
00421          sprintf(buf,"#%2d: *** EMPTY PALETTE ***\n",ii) ;
00422       } else {
00423          sprintf(buf,"#%2d: %s has" ,
00424                  ii,PALTAB_ARR_LABEL(GPT,ii) ); nbuf = strlen(buf) ;
00425          nn = 0 ;
00426          for( jj=NPANE_MIN ; jj <= NPANE_MAX ; jj++ ){
00427             if( (pp=PALTAB_ARR_PSGN(GPT,ii,jj)) != NULL ){
00428                if( verb ){ sprintf(buf+nbuf,"\n") ; nbuf = strlen(buf) ; }
00429                sprintf(buf+nbuf," [%d]",jj) ; nn++ ; nbuf = strlen(buf) ;
00430                if( verb ){
00431                   for( kk=0 ; kk < jj ; kk++ ){
00432                      sprintf(buf+nbuf,"\n  %s -> %f",
00433                              dc->ovc->label_ov[pp->col[kk]] , pp->val[kk] ) ;
00434                      nbuf = strlen(buf) ;
00435                   }
00436                } else {
00437                   if(nn%10 == 0){sprintf(buf+nbuf,"\n       "); nbuf=strlen(buf);}
00438                }
00439             }
00440             if( (pp=PALTAB_ARR_PPOS(GPT,ii,jj)) != NULL ){
00441                if( verb ){ sprintf(buf+nbuf,"\n") ; nbuf = strlen(buf) ; }
00442                sprintf(buf+nbuf," [%d+]",jj) ; nn++ ; nbuf = strlen(buf) ;
00443                if( verb ){
00444                   for( kk=0 ; kk < jj ; kk++ ){
00445                      if( pp->col[kk] >= 0 ) strcpy(s1,dc->ovc->label_ov[pp->col[kk]]) ;
00446                      else                   strcpy(s1,"IGNORE") ;
00447 
00448                      if( pp->val[kk] != PAL_FIGNORE ) sprintf(s2,"%f",pp->val[kk]) ;
00449                      else                             strcpy(s2,"IGNORE") ;
00450 
00451                      sprintf(buf+nbuf,"\n  %s -> %s", s1,s2 ) ;
00452                      nbuf = strlen(buf) ;
00453                   }
00454                } else {
00455                   if(nn%10 == 0){sprintf(buf+nbuf,"\n       "); nbuf=strlen(buf);}
00456                }
00457             }
00458          }
00459               if(         nn    == 0) sprintf(buf+nbuf," nothing \n") ;
00460          else if( verb || nn%10 != 0) sprintf(buf+nbuf,"\n") ;
00461       }
00462       nbuf = strlen(buf) ;
00463       if( nbuf+nuuu+2 > nsss ){
00464          nsss = nbuf+nuuu+128 ;
00465          sss = (char *) realloc( sss , sizeof(char) * nsss ) ;
00466       }
00467       strcat(sss,buf) ; nuuu = strlen(sss) ;
00468    }
00469    RETURN(sss) ;
00470 }

int label_in_PALTAB PBAR_palette_table   pt,
char *    lab
 

Definition at line 12 of file afni_setup.c.

References PALTAB_ARR_LABEL, and PALTAB_NUM.

Referenced by AFNI_process_setup().

00013 {
00014    int ii ;
00015    if( pt == NULL || PALTAB_NUM(pt) == 0 || lab == NULL || lab[0] == '\0' )
00016       return -1 ;
00017 
00018    for( ii=0 ; ii < PALTAB_NUM(pt) ; ii++ )
00019       if( strcmp( PALTAB_ARR_LABEL(pt,ii) , lab ) == 0 ) return ii ;
00020 
00021    return -1 ;
00022 }

void load_PBAR_palette_array MCW_pbar   pbar,
PBAR_palette_array   par,
int    fixim
 

Definition at line 474 of file afni_setup.c.

References alter_MCW_pbar(), MCW_pbar::bigmode, PBAR_palette::col, MCW_pbar::dc, ENTRY, FIX_SCALE_SIZE, HIDE_SCALE, MCW_DCOV::ncol_ov, NPANE_MAX, NPANE_MIN, MCW_DC::ovc, MCW_pbar::ovin_save, PAL_FIGNORE, MCW_pbar::parent, PBAR_palette_array::ppos, PBAR_palette_array::psgn, MCW_pbar::pval_save, and PBAR_palette::val.

Referenced by AFNI_palette_av_CB(), RCREND_palette_av_CB(), and REND_palette_av_CB().

00475 {
00476    int ii , jj , jm , nn ;
00477    PBAR_palette *pp ;
00478 
00479 ENTRY("load_PBAR_palette_array") ;
00480 
00481    if( pbar == NULL || par == NULL ) EXRETURN ;
00482 
00483    nn = 0 ;
00484    for( jj=NPANE_MIN ; jj <= NPANE_MAX ; jj++ ){
00485       pp = par->psgn[jj] ; jm = 0 ;
00486       if( pp != NULL ){
00487          if( pp->val[0] != PAL_FIGNORE ){
00488             for( ii=0 ; ii < jj ; ii++ )
00489                pbar->pval_save[jj][ii][jm] = pp->val[ii] ;
00490             pbar->pval_save[jj][jj][jm] = - pp->val[0] ;  /* reflection */
00491          }
00492 
00493          for( ii=0 ; ii < jj ; ii++ )
00494             if( pp->col[ii] >= 0 && pp->col[ii] < pbar->dc->ovc->ncol_ov )
00495                pbar->ovin_save[jj][ii][jm] = pp->col[ii] ;
00496 
00497          nn++ ;
00498       }
00499 
00500       pp = par->ppos[jj] ; jm = 1 ;
00501       if( pp != NULL ){
00502          if( pp->val[0] != PAL_FIGNORE ){
00503             for( ii=0 ; ii < jj ; ii++ )
00504                pbar->pval_save[jj][ii][jm] = pp->val[ii] ;
00505             pbar->pval_save[jj][jj][jm] = 0.0 ;  /* zero based */
00506          }
00507 
00508          for( ii=0 ; ii < jj ; ii++ )
00509             if( pp->col[ii] >= 0 && pp->col[ii] < pbar->dc->ovc->ncol_ov )
00510                pbar->ovin_save[jj][ii][jm] = pp->col[ii] ;
00511 
00512          nn++ ;
00513       }
00514    }
00515 
00516    if( nn > 0 && !pbar->bigmode ){
00517       Three_D_View * im3d = (Three_D_View *) pbar->parent ;
00518       if( fixim ){ HIDE_SCALE(im3d) ; }
00519       alter_MCW_pbar( pbar , 0 , NULL ) ;
00520       if( fixim ){ FIX_SCALE_SIZE(im3d) ; }
00521    }
00522    EXRETURN ;
00523 }
 

Powered by Plone

This site conforms to the following standards: