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  

plug_coorder.c

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 #include "afni.h"
00008 
00009 #ifndef ALLOW_PLUGINS
00010 #  error "Plugins not properly set up -- see machdep.h"
00011 #endif
00012 
00013 /***********************************************************************
00014   Plugin to switch the coordinate display order
00015 ************************************************************************/
00016 
00017 /*--------------------- string to 'help' the user --------------------*/
00018 
00019 static char helpstring[] =
00020   "Purpose: control the AFNI display of coordinates.\n"
00021   "\n"
00022   "The input 'Order' specifies which anatomical directions are to\n"
00023   "be displayed in the AFNI control window as the -x, -y, and -z\n"
00024   "axes, respectively.\n"
00025   "\n"
00026   "For example, the 'Dicom' order is equivalent to 'RAI', which\n"
00027   "means that\n"
00028   "  -x = Right      [and so +x = Left     ]\n"
00029   "  -y = Anterior   [    so +y = Posterior]\n"
00030   "  -z = Inferior   [    so +z = Superior ]\n"
00031   "\n"
00032   "The 'flipped' order is 'LPI', which is used in many journals.\n"
00033   "See the output of 'afni -help' for more information.\n"
00034   "\n"
00035   "After you make your choice, you must press one of the\n"
00036   "'Set' buttons for the plugin to send its data to AFNI.\n"
00037   "Author -- RW Cox"
00038 ;
00039 
00040 /*--------------------- strings for output format --------------------*/
00041 
00042 static char * cord_strings[] = {
00043  "Dicom" , "Flipped" ,
00044   "RAI" , "RAS" , "RPI" , "RPS" , "RIA" , "RIP" , "RSA" , "RSP" ,
00045   "LAI" , "LAS" , "LPI" , "LPS" , "LIA" , "LIP" , "LSA" , "LSP" ,
00046   "AIR" , "ASR" , "PIR" , "PSR" , "IAR" , "IPR" , "SAR" , "SPR" ,
00047   "AIL" , "ASL" , "PIL" , "PSL" , "IAL" , "IPL" , "SAL" , "SPL" ,
00048   "IRA" , "SRA" , "IRP" , "SRP" , "ARI" , "PRI" , "ARS" , "PRS" ,
00049   "ILA" , "SLA" , "ILP" , "SLP" , "ALI" , "PLI" , "ALS" , "PLS"
00050 } ;
00051 
00052 #define NUM_CORD_STRINGS (sizeof(cord_strings)/sizeof(char *))
00053 
00054 /*----------------- prototypes for internal routines -----------------*/
00055 
00056 static char * CORD_main( PLUGIN_interface * ) ;  /* the entry point */
00057 
00058 /***********************************************************************
00059    Set up the interface to the user:
00060     1) Create a new interface using "PLUTO_new_interface";
00061 
00062     2) For each line of inputs, create the line with "PLUTO_add_option"
00063          (this line of inputs can be optional or mandatory);
00064 
00065     3) For each item on the line, create the item with
00066         "PLUTO_add_dataset" for a dataset chooser,
00067         "PLUTO_add_string"  for a string chooser,
00068         "PLUTO_add_number"  for a number chooser.
00069 ************************************************************************/
00070 
00071 
00072 DEFINE_PLUGIN_PROTOTYPE
00073 
00074 PLUGIN_interface * PLUGIN_init( int ncall )
00075 {
00076    PLUGIN_interface * plint ;     /* will be the output of this routine */
00077    int meth ;
00078 
00079    if( ncall > 0 ) return NULL ;  /* only one interface */
00080 
00081    /*---------------- set titles and call point ----------------*/
00082 
00083    plint = PLUTO_new_interface( "Coord Order" ,
00084                                 "Coordinate Order Display" ,
00085                                 helpstring ,
00086                                 PLUGIN_CALL_VIA_MENU , CORD_main  ) ;
00087 
00088    PLUTO_add_hint( plint , "Coordinate Order Display" ) ;
00089 
00090    PLUTO_set_sequence( plint , "A:afnicontrol:display" ) ;
00091 
00092    PLUTO_set_runlabels( plint , "Set+Keep" , "Set+Close" ) ;  /* 04 Nov 2003 */
00093 
00094    /*---------- 2nd line: other inputs ----------*/
00095 
00096    PLUTO_add_option( plint ,
00097                      "Input" ,  /* label at left of input line */
00098                      "Input" ,  /* tag to return to plugin */
00099                      TRUE       /* is this mandatory? */
00100                    ) ;
00101 
00102    meth = PLUTO_string_index( GLOBAL_library.cord.orcode ,
00103                               NUM_CORD_STRINGS ,
00104                               cord_strings ) ;
00105    if( meth < 0 || meth >= NUM_CORD_STRINGS ) meth = 0 ;
00106 
00107    PLUTO_add_string( plint ,
00108                      "Order" ,          /* label next to chooser button */
00109                      NUM_CORD_STRINGS , /* number of strings to choose among */
00110                      cord_strings ,     /* list of strings to choose among */
00111                      meth               /* index of default string */
00112                    ) ;
00113 
00114    /*--------- done with interface setup ---------*/
00115 
00116    return plint ;
00117 }
00118 
00119 /***************************************************************************
00120   Main routine for this plugin (will be called from AFNI).
00121   If the return string is not NULL, some error transpired, and
00122   AFNI will popup the return string in a message box.
00123 ****************************************************************************/
00124 
00125 static char * CORD_main( PLUGIN_interface * plint )
00126 {
00127    char * str ;                 /* strings from user */
00128 
00129    /*--------- go to next input line ---------*/
00130 
00131    PLUTO_next_option(plint) ;
00132 
00133    str = PLUTO_get_string(plint) ;      /* get string item (the method) */
00134 
00135    MCW_strncpy(GLOBAL_argopt.orient_code,str,4) ;
00136    THD_coorder_fill( GLOBAL_argopt.orient_code , &GLOBAL_library.cord ) ;
00137    PLUTO_force_redisplay() ;
00138    return NULL ;
00139 }
 

Powered by Plone

This site conforms to the following standards: