Doxygen Source Code Documentation
xxx.c File Reference
#include "coxplot.h"#include <X11/Intrinsic.h>#include <X11/StringDefs.h>#include <X11/Shell.h>#include <Xm/XmAll.h>#include "math.h"Go to the source code of this file.
Defines | |
| #define | STATUS(str) fprintf(stderr,"-- " str "\n") |
| #define | NX 90 |
| #define | NY 90 |
| #define | DEATH |
| #define | LABEL_ARG(str) XtVaTypedArg , XmNlabelString , XmRString , (str) , strlen(str)+1 |
Functions | |
| void | make_plot (void) |
| void | elvis_CB (Widget w, XtPointer cd, XtPointer cb) |
| void | fred_CB (Widget w, XtPointer qd, XtPointer qb) |
| int | main (int argc, char *argv[]) |
Variables | |
| char * | vcl [] |
| XImage * | xim = NULL |
| int | xim_ww = 0 |
| int | xim_hh = 0 |
| int | need_plot = 1 |
Define Documentation
|
|
Definition at line 154 of file coxplot/xxx.c. |
|
|
|
|
|
|
|
|
|
|
|
Definition at line 23 of file coxplot/xxx.c. |
Function Documentation
|
||||||||||||||||
|
Definition at line 120 of file coxplot/xxx.c. References ev, make_plot(), memplot_to_X11, memplot_to_X11_free, set_active_memplot(), set_X11_background(), and STATUS. Referenced by main().
00121 {
00122 XmDrawingAreaCallbackStruct * cbs = (XmDrawingAreaCallbackStruct *) cb ;
00123 XExposeEvent * ev = (XExposeEvent *) cbs->event ;
00124 int start , end ;
00125 static int ncall = 0 ;
00126
00127 if( cbs->reason != XmCR_EXPOSE || ev->count > 0 ) return ;
00128
00129 STATUS("enter elvis_CB") ;
00130
00131 if( need_plot ){
00132 make_plot() ;
00133 set_X11_background( XtDisplay(w) , XtWindow(w) , 255,255,255 ) ;
00134 }
00135 XClearWindow( XtDisplay(w) , XtWindow(w) ) ;
00136
00137 #if 1
00138 if( ncall%2 == 0 ) set_active_memplot( "Elvis" ) ;
00139 else set_active_memplot( "Pelvis" ) ;
00140 ncall++ ;
00141 #endif
00142
00143 STATUS("XClearWindow") ;
00144
00145 start = end = 0 ;
00146 #if 0
00147 memplot_to_X11( XtDisplay(w) , XtWindow(w) ) ;
00148 #else
00149 memplot_to_X11_free( XtDisplay(w) , XtWindow(w) ) ;
00150 #endif
00151 return ;
00152 }
|
|
||||||||||||||||
|
Definition at line 155 of file coxplot/xxx.c. References X11_colordef::bb, X11_colordef::bbmask, X11_colordef::bbshift, X11_colordef::classKRH, X11_colordef::depth, FREE_X11_colordef, get_X11_colordef(), X11_colordef::gg, X11_colordef::ggmask, X11_colordef::ggshift, X11_colordef::ncolors, X11_colordef::rr, X11_colordef::rrmask, and X11_colordef::rrshift. Referenced by main().
00156 {
00157 #ifdef DEATH
00158 exit(0) ;
00159 #else
00160 X11_colordef * cd ;
00161
00162 cd = get_X11_colordef( XtDisplay(w) , XtWindow(w) ) ;
00163
00164 if( cd == NULL ){
00165 fprintf(stderr,"get_X11_colordef fails!\n") ; return ;
00166 }
00167
00168 if( cd->classKRH == TrueColor ){
00169 fprintf(stderr,"get_X11_colordef: visual class=TrueColor depth=%d\n"
00170 " masks: red = %x green = %x blue = %x\n"
00171 " shifts: red = %d green = %d blue = %d\n",
00172 cd->depth ,
00173 cd->rrmask , cd->ggmask , cd->bbmask ,
00174 cd->rrshift , cd->ggshift , cd->bbshift ) ;
00175
00176 } else if ( cd->classKRH == PseudoColor ){
00177 int ii ;
00178 fprintf(stderr,"get_X11_colordef: visual class=PseudoColor depth=%d colors=%d\n",
00179 cd->depth , cd->ncolors ) ;
00180 for( ii=0 ; ii < cd->ncolors ; ii++ ){
00181 fprintf(stderr," %3d: r=%4x g=%4x b=%4x\n",
00182 ii,cd->rr[ii],cd->gg[ii],cd->bb[ii]) ;
00183 }
00184 }
00185
00186 FREE_X11_colordef(cd) ;
00187 #endif /* DEATH */
00188 }
|
|
||||||||||||
|
convert DTIStudio fiber format data to SUMA segment data Definition at line 190 of file coxplot/xxx.c. References argc, dpy, elvis_CB(), fred_CB(), LABEL_ARG, STATUS, top, xim_hh, and xim_ww.
00191 {
00192 XtAppContext app; /* the application context */
00193 Display *dpy; /* display */
00194 Colormap colormap; /* created colormap */
00195 XVisualInfo vinfo; /* template for find visual */
00196 Visual *vis ; /* the Visual itself */
00197 XVisualInfo *vinfo_list; /* returned list of visuals */
00198 int count; /* number of matchs (only 1?) */
00199 int vid , stat ;
00200 Widget fred , fff , top ;
00201
00202 if( argc < 2 ){ fprintf(stderr,"Usage: xxx visid\n") ; exit(0) ; }
00203
00204 top = XtVaAppInitialize( &app , "xxx" , NULL , 0 , &argc,argv , NULL,NULL ) ;
00205 dpy = XtDisplay (top);
00206
00207 STATUS("XtVaAppInitialize") ;
00208
00209 vid = strtol( argv[1] , NULL , 0 ) ;
00210 vinfo.visualid = (VisualID) vid ;
00211 vinfo_list = XGetVisualInfo (dpy, VisualIDMask, &vinfo, &count);
00212 if( count == 0 || vinfo_list == NULL ){
00213 fprintf(stderr,"no such visual\n");exit(1);
00214 }
00215 vinfo = vinfo_list[0] ;
00216
00217 STATUS("XGetVisualInfo") ;
00218
00219 vid = vinfo.visualid ;
00220 vis = vinfo.visual ;
00221
00222 if( vis != DefaultVisual(dpy,vinfo.screen) ){
00223 colormap = XCreateColormap( dpy, RootWindowOfScreen(XtScreen(top)) ,
00224 vis , AllocNone ) ;
00225 STATUS("XCreateColormap") ;
00226 } else {
00227 colormap = DefaultColormap(dpy,vinfo.screen) ;
00228 STATUS("DefaultColormap") ;
00229 }
00230
00231 XtVaSetValues( top ,
00232 XtNborderColor , 0 ,
00233 XtNbackground , 0 ,
00234 XtNdepth , vinfo.depth ,
00235 XtNcolormap , colormap ,
00236 XtNvisual , vis ,
00237 NULL ) ;
00238
00239 STATUS("XtVaSetValues") ;
00240
00241 fff = XtVaCreateWidget( "dialog" , xmFormWidgetClass , top ,
00242 XmNborderWidth , 0 ,
00243 NULL ) ;
00244
00245 STATUS("XtVaCreateWidget") ;
00246
00247 #ifndef LABEL_ARG
00248 #define LABEL_ARG(str) \
00249 XtVaTypedArg , XmNlabelString , XmRString , (str) , strlen(str)+1
00250 #endif
00251
00252 fred = XtVaCreateManagedWidget( "dialog" , xmPushButtonWidgetClass , fff ,
00253 LABEL_ARG("Death") ,
00254 XmNtopAttachment , XmATTACH_FORM ,
00255 XmNleftAttachment , XmATTACH_FORM ,
00256 XmNrightAttachment , XmATTACH_FORM ,
00257 NULL ) ;
00258 XtAddCallback( fred , XmNactivateCallback , fred_CB , NULL ) ;
00259
00260 STATUS("XtVaCreateManagedWidget: button") ;
00261
00262 fred = XtVaCreateManagedWidget( "dialog" , xmDrawingAreaWidgetClass , fff ,
00263 XmNtopAttachment , XmATTACH_WIDGET ,
00264 XmNtopWidget , fred ,
00265 XmNleftAttachment , XmATTACH_FORM ,
00266 XmNrightAttachment , XmATTACH_FORM ,
00267 XmNbottomAttachment , XmATTACH_FORM ,
00268 NULL ) ;
00269
00270 XtAddCallback( fred , XmNexposeCallback , elvis_CB , NULL ) ;
00271
00272 STATUS("XtVaCreateManagedWidget: drawing area") ;
00273
00274 xim_ww = xim_hh = 77 ;
00275
00276 XtVaSetValues( top ,
00277 XmNwidth , xim_ww ,
00278 XmNheight , xim_hh+40 ,
00279 NULL ) ;
00280
00281 XtManageChild(fff) ;
00282 XtRealizeWidget(top);
00283
00284 STATUS("XtVaCreateManagedWidget: realize") ;
00285
00286 XtAppMainLoop(app);
00287
00288 exit(0); /* never reached */
00289 }
|
|
|
Definition at line 25 of file coxplot/xxx.c. References a, c, create_memplot(), free, malloc, need_plot, nline_active_memplot(), plotpak_frstpt(), plotpak_periml(), plotpak_pwritf(), plotpak_set(), plotpak_srface(), plotpak_vector(), set_color_memplot(), set_thick_memplot(), and STATUS. Referenced by elvis_CB().
00026 {
00027 integer ii,jj,kk,ll ;
00028 float a,b,c,d,e,f,g,h ;
00029
00030 /*----- make the graph plot -----*/
00031
00032 STATUS("enter make_plot") ;
00033
00034 ii = create_memplot( "Elvis" , 0.0 ) ;
00035 if( ii != 0 ){ fprintf(stderr,"Can't create memplot Elvis!\n") ; exit(1) ; }
00036
00037 STATUS("created Elvis") ;
00038
00039 set_color_memplot( 0.0 , 0.0 , 0.0 ) ;
00040 set_thick_memplot( 0.0 ) ;
00041
00042 STATUS("set color and thickness") ;
00043
00044 plotpak_set( 0.1,1.25 , 0.1,0.95 , 0.0,10.0 , 0.0,5.0 , 1 ) ;
00045
00046 STATUS("plotpak_set") ;
00047
00048 plotpak_periml( 5,10 , 5,10 ) ;
00049
00050 STATUS("drew perimeter") ;
00051
00052 set_color_memplot( 0.0 , 0.0 , 0.9 ) ;
00053 set_thick_memplot( 0.002 ) ;
00054 plotpak_frstpt( 0.0 , 0.0 ) ;
00055 for( ii=0 ; ii < 1000 ; ii++ ){
00056 a = 0.01 * ii ; b = sin(a) ; b = 5.0 * b * b / (1.0+0.1*a) ;
00057 plotpak_vector( a , b ) ;
00058 }
00059
00060 STATUS("drew sin") ;
00061
00062 set_color_memplot( 0.9 , 0.0 , 0.0 ) ;
00063 set_thick_memplot( 0.005 ) ;
00064 plotpak_frstpt( 0.0 , 5.0 ) ;
00065 for( ii=0 ; ii < 1000 ; ii++ ){
00066 a = 0.01 * ii ; b = cos(a) ; b = 5.0 * b * b / (1.0+0.1*a) ;
00067 plotpak_vector( a , b ) ;
00068 }
00069
00070 STATUS("drew cos") ;
00071
00072 fprintf(stderr,"-- Created memplot Elvis: %d\n",nline_active_memplot()) ;
00073
00074 #if 1
00075 /*----- make the surface plot -----*/
00076
00077 ii = create_memplot( "Pelvis" , 1.0 ) ;
00078 if( ii != 0 ){ fprintf(stderr,"Can't create memplot Pelvis!\n") ; exit(1) ; }
00079
00080 STATUS("created Pelvis") ;
00081
00082 #define NX 90
00083 #define NY 90
00084 { float * x , * y , * z , dx , dy ;
00085 x = (float *) malloc( sizeof(float) * NX ) ;
00086 y = (float *) malloc( sizeof(float) * NY ) ;
00087 z = (float *) malloc( sizeof(float) * NX*NY ) ;
00088 dx = 2.0/(NX-1.0) ; dy = 2.0/(NY-1.0) ;
00089 for( ii=0 ; ii < NX ; ii++ ) x[ii] = -1.0 + ii * dx ;
00090 for( ii=0 ; ii < NY ; ii++ ) y[ii] = -1.0 + ii * dy ;
00091 for( jj=0 ; jj < NY ; jj++ ){
00092 for( ii=0 ; ii < NX ; ii++ )
00093 z[ii+jj*NX] = sin( 3.0*(x[ii]-y[jj]) + 10.0*x[ii]*y[jj] )
00094 / ( 1.0 + x[ii]*x[ii] + y[jj]*y[jj] ) ;
00095 }
00096
00097 STATUS("created srface arrays") ;
00098
00099 set_thick_memplot( 0.0 ) ;
00100 set_color_memplot( 0.0 , 0.0 , 0.0 ) ;
00101 plotpak_srface( x , y , z , NX , NY , 45.0 , 33.0 ) ;
00102
00103 STATUS("plotpak_srface") ;
00104 free((char *)x) ; free((char *)y) ; free((char *)z) ;
00105 STATUS("free srface arrays") ;
00106
00107 set_color_memplot( 1.0 , 0.0 , 0.0 ) ;
00108 plotpak_set( 0.0,1.0 , 0.0,1.0 , 0.0,1.0 , 0.0,1.0 , 1 ) ;
00109 plotpak_pwritf( 0.5 , 0.94 , "Sample Surface Plot" , 20 , 0 , 0 ) ;
00110 STATUS("pwritf") ;
00111
00112 fprintf(stderr,"-- Created memplot Pelvis: %d\n",nline_active_memplot()) ;
00113 }
00114 #endif
00115
00116 need_plot = 0 ;
00117 return ;
00118 }
|
Variable Documentation
|
|
Definition at line 21 of file coxplot/xxx.c. Referenced by make_plot(). |
|
|
Initial value: { "StaticGray" , "GrayScale" , "StaticColor" ,
"PseudoColor" , "TrueColor" , "DirectColor" }Definition at line 12 of file coxplot/xxx.c. |
|
|
Definition at line 15 of file coxplot/xxx.c. |
|
|
Definition at line 17 of file coxplot/xxx.c. Referenced by main(). |
|
|
Definition at line 16 of file coxplot/xxx.c. Referenced by main(). |