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  

plot_ps2.c

Go to the documentation of this file.
00001 #include "coxplot.h"
00002 
00003 /*****************************************************************************
00004   This software is copyrighted and owned by the Medical College of Wisconsin.
00005   See the file README.Copyright for details.
00006 ******************************************************************************/
00007 
00008 /*------------------------------------------------------------------------
00009   Routine to render a memplot into a PostScript file.
00010   (Also see the file ps_plot.c.)
00011 --------------------------------------------------------------------------*/
00012 
00013 #ifdef PSIZE
00014 #undef PSIZE
00015 #endif
00016 #define PSIZE 4096
00017 
00018 void memplot_to_postscript( char * fname , MEM_plotdata * mp )
00019 {
00020    int ii , nline ;
00021    float old_thick , old_color , new_color , new_thick ;
00022    int   x1,y1 , x2,y2 ;
00023    int   skip ;
00024 
00025    /*-- sanity checks --*/
00026 
00027    if( fname == NULL || fname[0] == '\0' || mp == NULL ) return ;
00028 
00029    nline = MEMPLOT_NLINE(mp) ; if( nline < 1 ) return ;
00030 
00031    /*-- open the output file --*/
00032 
00033    if( ! ps_openpl(fname) ) return ;
00034    ps_space( 0,0,PSIZE,PSIZE ) ;
00035 
00036    old_color = -1.0 ;
00037    old_thick = -THCODE_INVALID ;
00038 
00039    /*-- loop over lines, scale and plot --*/
00040 
00041    for( ii=0 ; ii < nline ; ii++ ){
00042 
00043       skip = 0 ;
00044 
00045       /* check if need to change color or thickness of line */
00046 
00047       new_color = MEMPLOT_COL(mp,ii) ;
00048       if( new_color != old_color ){
00049          float rr=COL_TO_RRR(new_color) ,
00050                gg=COL_TO_GGG(new_color) , bb=COL_TO_BBB(new_color) ;
00051          ps_setrgb( rr , gg , bb ) ;
00052          old_color = new_color ;
00053       }
00054       new_thick = MEMPLOT_TH(mp,ii) ;
00055       if( new_thick < 0.0 ){           /* 21 Mar 2001: negative thickness codes */
00056          int thc = (int)(-new_thick) ;
00057          switch( thc ){
00058             case THCODE_RECT:{        /* rectangle */
00059                x1 = 0.499 + PSIZE * (1.0 - MEMPLOT_Y1(mp,ii)) ;
00060                x2 = 0.499 + PSIZE * (1.0 - MEMPLOT_Y2(mp,ii)) ;
00061                y1 = 0.499 + PSIZE * MEMPLOT_X1(mp,ii) ;
00062                y2 = 0.499 + PSIZE * MEMPLOT_X2(mp,ii) ;
00063                ps_rect( x1,y1 , x2,y2 ) ;
00064                skip = 1 ;
00065             }
00066             break ;
00067 
00068             case THCODE_CIRC:{        /* circle */
00069                x1 = 0.499 + PSIZE * (1.0 - MEMPLOT_Y1(mp,ii)) ;
00070                y1 = 0.499 + PSIZE * MEMPLOT_X1(mp,ii) ;
00071                x2 = 0.499 + PSIZE * MEMPLOT_X2(mp,ii) ;
00072                ps_circle( x1,y1 , x2 ) ;
00073                skip = 1 ;
00074             }
00075             break ;
00076          }
00077       } else if( new_thick != old_thick ){  /* old code to change line thickness */
00078          float th = PSIZE * new_thick ;
00079          if( th <= 0.0 ) th = 1.0 ;
00080          ps_setwidth( th ) ;
00081          old_thick = new_thick ;
00082       }
00083 
00084       if( !skip ){
00085         /* scale coords (also see zzphph.f) */
00086 
00087         x1 = 0.499 + PSIZE * (1.0 - MEMPLOT_Y1(mp,ii)) ;
00088         x2 = 0.499 + PSIZE * (1.0 - MEMPLOT_Y2(mp,ii)) ;
00089         y1 = 0.499 + PSIZE * MEMPLOT_X1(mp,ii) ;
00090         y2 = 0.499 + PSIZE * MEMPLOT_X2(mp,ii) ;
00091 
00092         ps_line( x1,y1 , x2,y2 ) ;
00093       }
00094    }
00095 
00096    /*-- done --*/
00097 
00098    ps_closepl() ;
00099    return ;
00100 }
 

Powered by Plone

This site conforms to the following standards: