Doxygen Source Code Documentation
Main Page Alphabetical List Data Structures File List Data Fields Globals Search
mri_coxplot.c
Go to the documentation of this file.00001 #include "mrilib.h"
00002 #include "coxplot.h"
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 static int box_xbot=0 , box_xtop=0 ,
00018 box_ybot=0 , box_ytop=0 ;
00019
00020 void set_memplot_RGB_box( int xbot, int ybot, int xtop, int ytop )
00021 {
00022 if( xbot < xtop && ybot < ytop ){
00023 box_xbot = xbot ; box_ybot = ybot ;
00024 box_xtop = xtop ; box_ytop = ytop ;
00025 } else {
00026 box_xbot = box_ybot = box_xtop = box_ytop = 0 ;
00027 }
00028 }
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041 void memplot_to_RGB_sef( MRI_IMAGE *im , MEM_plotdata * mp ,
00042 int start , int end , int freee )
00043 {
00044 byte rrr=0,ggg=0,bbb=0 ;
00045 int ii , nline , same ;
00046 float old_thick , old_color , new_color , new_thick ;
00047 float scal,xscal,yscal , xoff,yoff ;
00048 int x1,y1 , x2,y2 ;
00049 int skip ;
00050
00051 ENTRY("memplot_to_RGB_sef") ;
00052
00053
00054
00055 if( im == NULL || im->kind != MRI_rgb || mp == NULL ) EXRETURN ;
00056
00057 if( start < 0 ) start = 0 ;
00058
00059 nline = MEMPLOT_NLINE(mp) ;
00060 if( nline < 1 || start >= nline ) EXRETURN ;
00061
00062 if( end <= start || end > nline ) end = nline ;
00063
00064
00065
00066
00067 if( box_xbot >= box_xtop || box_ybot >= box_ytop ){
00068
00069 xscal = im->nx / mp->aspect ;
00070 yscal = im->ny / 1.0 ;
00071 xoff = yoff = 0.499 ;
00072
00073 } else {
00074
00075 xscal = box_xtop - box_xbot ;
00076 yscal = box_ytop - box_ybot ;
00077 xoff = box_xbot + 0.499 ;
00078 yoff = box_ybot + 0.499 ;
00079 }
00080
00081 if( !freee ){
00082 if( yscal < xscal ) xscal = yscal ;
00083 else yscal = xscal ;
00084 }
00085 scal = sqrt(fabs(xscal*yscal)) ;
00086
00087 old_color = -1.0 ;
00088 old_thick = -THCODE_INVALID ;
00089
00090
00091
00092 mri_draw_opacity( 1.0 ) ;
00093
00094 for( ii=start ; ii < end ; ii++ ){
00095
00096 skip = 0 ;
00097
00098
00099
00100 new_color = MEMPLOT_COL(mp,ii) ;
00101 if( new_color != old_color ){
00102 float rr=COL_TO_RRR(new_color) ,
00103 gg=COL_TO_GGG(new_color) , bb=COL_TO_BBB(new_color) ;
00104
00105 #if 0
00106 fprintf(stderr,"Changing color to %f %f %f\n",rr,gg,bb) ;
00107 #endif
00108
00109 rrr = ZO_TO_TFS(rr) ; ggg = ZO_TO_TFS(gg) ; bbb = ZO_TO_TFS(bb) ;
00110 old_color = new_color ;
00111 }
00112
00113 new_thick = MEMPLOT_TH(mp,ii) ;
00114 if( new_thick < 0.0 ){
00115 int thc = (int)(-new_thick) ;
00116 switch( thc ){
00117 case THCODE_RECT:{
00118 int xb,yb , xt,yt ;
00119 int w,h ;
00120 x1 = rint( xoff + xscal * MEMPLOT_X1(mp,ii) ) ;
00121 x2 = rint( xoff + xscal * MEMPLOT_X2(mp,ii) ) ;
00122 y1 = rint( yoff + yscal * (1.0 - MEMPLOT_Y1(mp,ii)) ) ;
00123 y2 = rint( yoff + yscal * (1.0 - MEMPLOT_Y2(mp,ii)) ) ;
00124 if( x1 < x2 ){ xb=x1; xt=x2; } else { xb=x2; xt=x1; }
00125 if( y1 < y2 ){ yb=y1; yt=y2; } else { yb=y2; yt=y1; }
00126 w = xt-xb+1 ; h = yt-yb+1 ;
00127 mri_drawfilledrectangle( im , xb,yb , w,h , rrr,ggg,bbb ) ;
00128 skip = 1 ;
00129 }
00130 break ;
00131
00132 case THCODE_OPAC:{
00133 mri_draw_opacity( MEMPLOT_X1(mp,ii) ) ;
00134 skip = 1 ;
00135 }
00136 break ;
00137 }
00138
00139 } else if( new_thick != old_thick ){
00140
00141 old_thick = new_thick ;
00142
00143 }
00144
00145
00146
00147 if( !skip ){
00148 x1 = (int)( xoff + xscal * MEMPLOT_X1(mp,ii) ) ;
00149 x2 = (int)( xoff + xscal * MEMPLOT_X2(mp,ii) ) ;
00150 y1 = (int)( yoff + yscal * (1.0 - MEMPLOT_Y1(mp,ii)) ) ;
00151 y2 = (int)( yoff + yscal * (1.0 - MEMPLOT_Y2(mp,ii)) ) ;
00152
00153
00154
00155 mri_drawline( im , x1,y1 , x2,y2 , rrr,ggg,bbb ) ;
00156 }
00157 }
00158
00159 set_memplot_RGB_box(0,0,0,0) ;
00160 EXRETURN ;
00161 }