[BACK]Return to plotsun.c CVS log [TXT][DIR] Up to [local] / OpenXM_contrib / pari / src / graph

Annotation of OpenXM_contrib/pari/src/graph/plotsun.c, Revision 1.1

1.1     ! maekawa     1: /*******************************************************************/
        !             2: /*                                                                 */
        !             3: /*                  HI-RES PLOT. SUNVIEW INTERFACE                 */
        !             4: /*                                                                 */
        !             5: /*******************************************************************/
        !             6: /* $Id: plotsun.c,v 1.1.1.1 1999/09/16 13:47:44 karim Exp $ */
        !             7: #include "pari.h"
        !             8: #include "rect.h"
        !             9: #include <suntool/sunview.h>
        !            10: #include <suntool/canvas.h>
        !            11: #include <suntool/textsw.h>
        !            12: #include <suntool/panel.h>
        !            13:
        !            14: typedef struct spoint {int x,y;} SPoint;
        !            15: typedef struct ssegment {int x1,y1,x2,y2;} SSegment;
        !            16: typedef struct srectangle {int x,y,width,height;} SRectangle;
        !            17:
        !            18: #define ISCR 1120 /* 1400 en haute resolution */
        !            19: #define JSCR 800  /* 1120 en haute resolution */
        !            20:
        !            21: void
        !            22: rectdraw0(long *w, long *x, long *y, long lw, long do_free)
        !            23: {
        !            24:   long *ptx,*pty,*numpoints,*numtexts,*xtexts,*ytexts;
        !            25:   long n,i,j,x0,y0;
        !            26:   long a,b,c,d,ne;
        !            27:   long rcnt[ROt_MAX+1];
        !            28:   char **texts;
        !            29:   PariRect *e;
        !            30:   RectObj *p1;
        !            31:
        !            32:   Frame ecran;
        !            33:   Canvas canevas;
        !            34:   Pixwin *pw;
        !            35:   Pixfont *font;
        !            36:   SPoint *points, **lines, *SLine;
        !            37:   SSegment *segments;
        !            38:   SRectangle *rectangles, SRec;
        !            39:
        !            40:   if (fork()) return;  /* parent process returns */
        !            41:
        !            42:   /* child process goes on */
        !            43:   freeall();  /* PARI stack isn't needed anymore, keep rectgraph */
        !            44:   PARI_get_plot(1);
        !            45:
        !            46:   rcnt[ROt_MV]=rcnt[ROt_PT]=rcnt[ROt_LN]=0;
        !            47:   rcnt[ROt_BX]=rcnt[ROt_MP]=rcnt[ROt_ML]=0;
        !            48:   rcnt[ROt_ST]=0;
        !            49:
        !            50:   for(i=0;i<lw;i++)
        !            51:   {
        !            52:     e=rectgraph[w[i]]; p1=RHead(e);
        !            53:     while(p1)
        !            54:     {
        !            55:       if(RoType(p1) != ROt_MP) rcnt[RoType(p1)]++;
        !            56:       else rcnt[ROt_PT] += RoMPcnt(p1);
        !            57:       p1=RoNext(p1);
        !            58:     }
        !            59:   }
        !            60:   points=(SPoint*)gpmalloc(rcnt[ROt_PT]*sizeof(SPoint));
        !            61:   segments=(SSegment*)gpmalloc(rcnt[ROt_LN]*sizeof(SSegment));
        !            62:   rectangles=(SRectangle*)gpmalloc(rcnt[ROt_BX]*sizeof(SRectangle));
        !            63:   lines=(SPoint**)gpmalloc(rcnt[ROt_ML]*sizeof(SPoint*));
        !            64:   numpoints=(long*)gpmalloc(rcnt[ROt_ML]*sizeof(long));
        !            65:   texts=(char**)gpmalloc(rcnt[ROt_ST]*sizeof(char*));
        !            66:   numtexts=(long*)gpmalloc(rcnt[ROt_ST]*sizeof(long));
        !            67:   xtexts=(long*)gpmalloc(rcnt[ROt_ST]*sizeof(long));
        !            68:   ytexts=(long*)gpmalloc(rcnt[ROt_ST]*sizeof(long));
        !            69:   rcnt[ROt_PT]=rcnt[ROt_LN]=rcnt[ROt_BX]=rcnt[ROt_ML]=rcnt[ROt_ST]=0;
        !            70:
        !            71:   for(i=0;i<lw;i++)
        !            72:   {
        !            73:     e=rectgraph[w[i]];p1=RHead(e);x0=x[i];y0=y[i];
        !            74:     while(p1)
        !            75:     {
        !            76:       switch(RoType(p1))
        !            77:       {
        !            78:        case ROt_PT:
        !            79:          points[rcnt[ROt_PT]].x=RoPTx(p1)+x0;
        !            80:          points[rcnt[ROt_PT]].y=RoPTy(p1)+y0;
        !            81:          rcnt[ROt_PT]++;break;
        !            82:        case ROt_LN:
        !            83:          segments[rcnt[ROt_LN]].x1=RoLNx1(p1)+x0;
        !            84:          segments[rcnt[ROt_LN]].y1=RoLNy1(p1)+y0;
        !            85:          segments[rcnt[ROt_LN]].x2=RoLNx2(p1)+x0;
        !            86:          segments[rcnt[ROt_LN]].y2=RoLNy2(p1)+y0;
        !            87:          rcnt[ROt_LN]++;break;
        !            88:        case ROt_BX:
        !            89:          a=rectangles[rcnt[ROt_BX]].x=RoBXx1(p1)+x0;
        !            90:          b=rectangles[rcnt[ROt_BX]].y=RoBXy1(p1)+y0;
        !            91:          rectangles[rcnt[ROt_BX]].width=RoBXx2(p1)+x0-a;
        !            92:          rectangles[rcnt[ROt_BX]].height=RoBXy2(p1)+y0-b;
        !            93:          rcnt[ROt_BX]++;break;
        !            94:        case ROt_MP:
        !            95:          ptx=RoMPxs(p1);pty=RoMPys(p1);
        !            96:          for(j=0;j<RoMPcnt(p1);j++)
        !            97:          {
        !            98:            points[rcnt[ROt_PT]+j].x=ptx[j]+x0;
        !            99:            points[rcnt[ROt_PT]+j].y=pty[j]+y0;
        !           100:          }
        !           101:          rcnt[ROt_PT]+=RoMPcnt(p1);break;
        !           102:        case ROt_ML:
        !           103:          ptx=RoMLxs(p1);pty=RoMLys(p1);
        !           104:          numpoints[rcnt[ROt_ML]]=RoMLcnt(p1);
        !           105:          lines[rcnt[ROt_ML]]=(SPoint*)gpmalloc(RoMLcnt(p1)*sizeof(SPoint));
        !           106:          for(j=0;j<RoMLcnt(p1);j++)
        !           107:          {
        !           108:            lines[rcnt[ROt_ML]][j].x=ptx[j]+x0;
        !           109:            lines[rcnt[ROt_ML]][j].y=pty[j]+y0;
        !           110:          }
        !           111:          rcnt[ROt_ML]++;break;
        !           112:         case ROt_ST:
        !           113:          texts[rcnt[ROt_ST]]=RoSTs(p1); numtexts[rcnt[ROt_ST]]=RoSTl(p1);
        !           114:          xtexts[rcnt[ROt_ST]]=RoSTx(p1)+x0; ytexts[rcnt[ROt_ST]]=RoSTy(p1)+y0;
        !           115:          rcnt[ROt_ST]++;break;
        !           116:        default: break;
        !           117:       }
        !           118:       p1=RoNext(p1);
        !           119:     }
        !           120:   }
        !           121:   ecran=window_create(NULL,FRAME,FRAME_LABEL,"rectplot",
        !           122:                       WIN_ERROR_MSG,"you must be in suntools",0);
        !           123:   canevas=window_create(ecran,CANVAS,WIN_HEIGHT,JSCR, WIN_WIDTH,ISCR,0);
        !           124:   window_fit(ecran);pw=canvas_pixwin(canevas);
        !           125:
        !           126:   font=pw_pfsysopen();
        !           127:   for(i=0;i<rcnt[ROt_PT];i++) pw_put(pw,points[i].x,points[i].y,1);
        !           128:   for(i=0;i<rcnt[ROt_LN];i++)
        !           129:     pw_vector(pw,segments[i].x1,segments[i].y1,
        !           130:               segments[i].x2,segments[i].y2,PIX_SRC,1);
        !           131:   for(i=0;i<rcnt[ROt_BX];i++)
        !           132:   {
        !           133:     SRec=rectangles[i];a=SRec.x;b=SRec.y;c=a+SRec.width;
        !           134:     d=b+SRec.height;
        !           135:     pw_vector(pw,a,b,c,b,PIX_SRC,1); pw_vector(pw,c,b,c,d,PIX_SRC,1);
        !           136:     pw_vector(pw,a,d,c,d,PIX_SRC,1); pw_vector(pw,a,b,a,d,PIX_SRC,1);
        !           137:   }
        !           138:   for(i=0;i<rcnt[ROt_ML];i++)
        !           139:   {
        !           140:     SLine=lines[i];
        !           141:     for(j=1;j<numpoints[i];j++)
        !           142:       pw_vector(pw,SLine[j-1].x,SLine[j-1].y,SLine[j].x,SLine[j].y,PIX_SRC,1);
        !           143:   }
        !           144:   for(i=0;i<rcnt[ROt_ST];i++)
        !           145:     for(j=0;texts[i][j];j++)
        !           146:       pw_char(pw,xtexts[i]+9*j,ytexts[i],PIX_SRC|PIX_DST,font,texts[i][j]);
        !           147:
        !           148:   window_main_loop(ecran);
        !           149:
        !           150:   free(points);free(segments);free(rectangles);
        !           151:   free(numpoints);for(i=0;i<rcnt[ROt_ML];i++) free(lines[i]);
        !           152:   free(lines);free(texts);free(numtexts);free(xtexts);free(ytexts);
        !           153:   if (do_free) { free(w); free(x); free(y); }
        !           154:   free_graph(); exit(0);
        !           155: }
        !           156:
        !           157: void
        !           158: PARI_get_plot(long fatal)
        !           159: {
        !           160:   if (pari_plot.init) return;
        !           161:
        !           162:   w_width = ISCR; w_height = JSCR;
        !           163:   f_height = 15; f_width = 9;
        !           164:   h_unit = 5; v_unit = 5;
        !           165:   pari_plot.init = 1;
        !           166: }
        !           167:
        !           168: long
        !           169: term_set(char *s)
        !           170: {
        !           171:   return 1;
        !           172: }
        !           173:
        !           174: long
        !           175: plot_outfile_set(char *s) { return 1; }
        !           176:
        !           177: void
        !           178: set_pointsize(double d)
        !           179: {
        !           180: }

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>