Doxygen Source Code Documentation
mri_coxplot.c File Reference
#include "mrilib.h"#include "coxplot.h"Go to the source code of this file.
Functions | |
| void | set_memplot_RGB_box (int xbot, int ybot, int xtop, int ytop) |
| void | memplot_to_RGB_sef (MRI_IMAGE *im, MEM_plotdata *mp, int start, int end, int freee) |
Variables | |
| int | box_xbot = 0 |
| int | box_xtop = 0 |
| int | box_ybot = 0 |
| int | box_ytop = 0 |
Function Documentation
|
||||||||||||||||||||||||
|
Actually do the rendering of a memplot into an RGB image.
Definition at line 41 of file mri_coxplot.c. References MEM_plotdata::aspect, box_xbot, box_xtop, box_ybot, box_ytop, COL_TO_BBB, COL_TO_GGG, COL_TO_RRR, ENTRY, MRI_IMAGE::kind, MEMPLOT_COL, MEMPLOT_NLINE, MEMPLOT_TH, MEMPLOT_X1, MEMPLOT_X2, MEMPLOT_Y1, MEMPLOT_Y2, mp, mri_draw_opacity(), mri_drawfilledrectangle(), mri_drawline(), MRI_IMAGE::nx, MRI_IMAGE::ny, set_memplot_RGB_box(), skip, x2, y1, and ZO_TO_TFS. Referenced by ISQ_save_jpeg(), ISQ_saver_CB(), and PLOT_matrix_gray().
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 /*--- check for madness ---*/
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 /*--- compute scaling from memplot objective
00065 coordinates to RGB window coordinates ---*/
00066
00067 if( box_xbot >= box_xtop || box_ybot >= box_ytop ){
00068
00069 xscal = im->nx / mp->aspect ; /* aspect = x-axis objective size */
00070 yscal = im->ny / 1.0 ; /* 1.0 = y-axis objective size */
00071 xoff = yoff = 0.499 ;
00072
00073 } else { /* scale to a given sub-box in the window */
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 ){ /* no aspect freedom ==> */
00082 if( yscal < xscal ) xscal = yscal ; /* use smaller scaling */
00083 else yscal = xscal ;
00084 }
00085 scal = sqrt(fabs(xscal*yscal)) ;
00086
00087 old_color = -1.0 ; /* these don't occur naturally */
00088 old_thick = -THCODE_INVALID ;
00089
00090 /*--- loop over lines, scale and plot ---*/
00091
00092 mri_draw_opacity( 1.0 ) ;
00093
00094 for( ii=start ; ii < end ; ii++ ){
00095
00096 skip = 0 ;
00097
00098 /* check if need to change color or thickness of line */
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 ){ /* special negative thickness codes */
00115 int thc = (int)(-new_thick) ;
00116 switch( thc ){
00117 case THCODE_RECT:{ /* rectangle */
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:{ /* opacity [22 Jul 2004] */
00133 mri_draw_opacity( MEMPLOT_X1(mp,ii) ) ;
00134 skip = 1 ;
00135 }
00136 break ;
00137 }
00138
00139 } else if( new_thick != old_thick ){ /* normal case: change line thickness */
00140
00141 old_thick = new_thick ; /* thickness not used at this time */
00142
00143 }
00144
00145 /* scale coords to ints (also see zzphph.f) */
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 /* draw it */
00154
00155 mri_drawline( im , x1,y1 , x2,y2 , rrr,ggg,bbb ) ;
00156 }
00157 }
00158
00159 set_memplot_RGB_box(0,0,0,0) ; /* clear box */
00160 EXRETURN ;
00161 }
|
|
||||||||||||||||||||
|
Definition at line 20 of file mri_coxplot.c. References box_xbot, box_xtop, box_ybot, and box_ytop. Referenced by memplot_to_RGB_sef().
|
Variable Documentation
|
|
Set a sub-box within a window into which the next RGB plot should be scaled. (0,0,0,0) args means use the whole window. After each drawing (memplot_to_RGB_sef), will be reset to the whole window anyway. ---------------------------------------------------------------------------- Definition at line 17 of file mri_coxplot.c. Referenced by memplot_to_RGB_sef(), and set_memplot_RGB_box(). |
|
|
Set a sub-box within a window into which the next RGB plot should be scaled. (0,0,0,0) args means use the whole window. After each drawing (memplot_to_RGB_sef), will be reset to the whole window anyway. ---------------------------------------------------------------------------- Definition at line 17 of file mri_coxplot.c. Referenced by memplot_to_RGB_sef(), and set_memplot_RGB_box(). |
|
|
Set a sub-box within a window into which the next RGB plot should be scaled. (0,0,0,0) args means use the whole window. After each drawing (memplot_to_RGB_sef), will be reset to the whole window anyway. ---------------------------------------------------------------------------- Definition at line 18 of file mri_coxplot.c. Referenced by memplot_to_RGB_sef(), and set_memplot_RGB_box(). |
|
|
Set a sub-box within a window into which the next RGB plot should be scaled. (0,0,0,0) args means use the whole window. After each drawing (memplot_to_RGB_sef), will be reset to the whole window anyway. ---------------------------------------------------------------------------- Definition at line 18 of file mri_coxplot.c. Referenced by memplot_to_RGB_sef(), and set_memplot_RGB_box(). |