version 1.6, 2002/07/11 03:34:34 |
version 1.8, 2002/07/20 02:28:08 |
|
|
/* $OpenXM: OpenXM_contrib2/asir2000/plot/smoothing.c,v 1.5 2001/04/07 10:53:15 takayama Exp $ */ |
/* $OpenXM: OpenXM_contrib2/asir2000/plot/smoothing.c,v 1.7 2002/07/11 12:35:03 takayama Exp $ */ |
#include "ca.h" |
#include "ca.h" |
#include "parse.h" |
#include "parse.h" |
#include "ox.h" |
#include "ox.h" |
|
|
|
|
static FILE *Fp = NULL; |
static FILE *Fp = NULL; |
|
|
static void polyLine_outputProlog(int xmin, int ymin, int xmax, int ymax); |
static void polyLine_outputProlog(int xmin, int ymin, int xmax, int ymax, int upsidedown); |
static void polyLine_outputEpilog(void); |
static void polyLine_outputEpilog(void); |
static void polyLine_error(char *s); |
static void polyLine_error(char *s); |
#define translateX(x) (x*MAG+PRINT_XOFFSET) |
#define translateX(x) (x*MAG+PRINT_XOFFSET) |
Line 31 static int polyLine_pline(struct canvas *can); |
|
Line 31 static int polyLine_pline(struct canvas *can); |
|
static int Strategy_generate_PS = 0; |
static int Strategy_generate_PS = 0; |
|
|
|
|
static void polyLine_outputProlog(int xmin, int ymin,int xmax, int ymax) { |
static void polyLine_outputProlog(int xmin, int ymin,int xmax, int ymax, int upsidedown) { |
fprintf(Fp,"%%!PS-Adobe-1.0\n"); |
fprintf(Fp,"%%!PS-Adobe-1.0\n"); |
fprintf(Fp,"%%%%BoundingBox: %d %d %d %d \n", |
fprintf(Fp,"%%%%BoundingBox: %d %d %d %d \n", |
PRINT_XOFFSET+xmin*MAG,PRINT_YOFFSET+ymin*MAG, |
PRINT_XOFFSET+xmin*MAG,PRINT_YOFFSET+ymin*MAG, |
Line 39 static void polyLine_outputProlog(int xmin, int ymin,i |
|
Line 39 static void polyLine_outputProlog(int xmin, int ymin,i |
|
fprintf(Fp,"%%%%Creator: This is generated by ifplot\n"); |
fprintf(Fp,"%%%%Creator: This is generated by ifplot\n"); |
fprintf(Fp,"%%%%Title: ifplot\n"); |
fprintf(Fp,"%%%%Title: ifplot\n"); |
fprintf(Fp,"%%%%EndComments: \n"); |
fprintf(Fp,"%%%%EndComments: \n"); |
|
if ( upsidedown ) |
|
fprintf(Fp,"[1 0 0 -1 0 %d] concat \n",2*PRINT_YOFFSET+(ymin+ymax)*MAG); |
fprintf(Fp,"0.1 setlinewidth \n"); |
fprintf(Fp,"0.1 setlinewidth \n"); |
fprintf(Fp,"2 setlinecap \n"); |
fprintf(Fp,"2 setlinecap \n"); |
fprintf(Fp,"2 setlinejoin \n"); |
fprintf(Fp,"2 setlinejoin \n"); |
Line 120 struct canvas *can; |
|
Line 122 struct canvas *can; |
|
|
|
generatePS_from_image(FILE *fp,XImage *image,int xsize, int ysize, |
generatePS_from_image(FILE *fp,XImage *image,int xsize, int ysize, |
int color[],int colorSize, |
int color[],int colorSize, |
struct canvas *can,struct xcolorForPS *tableOfxcolorForPS) { |
struct canvas *can,struct xcolorForPS *tableOfxcolorForPS, |
|
int upsidedown) { |
struct polyLine **pl; |
struct polyLine **pl; |
int plSize = 0; |
int plSize = 0; |
int *prev; |
int *prev; |
int *curr; |
int *curr; |
int i,x,y,c; |
int i,x,y,c; |
extern int Strategy_generate_PS; |
extern int Strategy_generate_PS; |
|
|
Xsize = xsize; |
Xsize = xsize; |
Ysize = ysize; |
Ysize = ysize; |
Fp = fp; |
Fp = fp; |
polyLine_outputProlog(0,0,Xsize,Ysize); |
polyLine_outputProlog(0,0,Xsize,Ysize,upsidedown); |
switch(Strategy_generate_PS) { |
switch(Strategy_generate_PS) { |
default: |
default: |
fprintf(Fp,"%% debug info : colorSize=%d\n",colorSize); |
fprintf(Fp,"%% debug info : colorSize=%d\n",colorSize); |
for (c=0; c<colorSize; c++) { |
for (c=0; c<colorSize; c++) { |
/* Set color by looking at tableOfxcolorForPS. |
/* Set color by looking at tableOfxcolorForPS. |
It has not yet been implemented. |
|
*/ |
*/ |
for (x=0; x<Xsize; x++) { |
fprintf(Fp,"%f %f %f setrgbcolor \n",(tableOfxcolorForPS[c]).r,(tableOfxcolorForPS[c]).g,(tableOfxcolorForPS[c]).b); |
for (y=0; y<Ysize; y++) { |
for (x=0; x<Xsize; x++) { |
if ((int) XGetPixel(image,x,y) == color[c]){ |
for (y=0; y<Ysize; y++) { |
fprintf(Fp," %d %d ", translateX(x),translateY(y) ); |
if ((tableOfxcolorForPS[c]).print && |
fprintf(Fp," ifplot_putpixel\n"); |
XGetPixel(image,x,y) == (tableOfxcolorForPS[c]).pixel){ |
} |
fprintf(Fp," %d %d ", translateX(x),translateY(y) ); |
} |
fprintf(Fp," ifplot_putpixel\n"); |
} |
} |
} |
} |
break; |
} |
|
} |
|
break; |
} |
} |
|
/* XXX : reset the color to black */ |
|
fprintf(Fp,"0 0 0 setrgbcolor \n"); |
polyLine_pline(can); |
polyLine_pline(can); |
polyLine_outputEpilog(); |
polyLine_outputEpilog(); |
} |
} |