=================================================================== RCS file: /home/cvs/OpenXM_contrib2/asir2000/plot/ox_plot_xevent.c,v retrieving revision 1.15 retrieving revision 1.18 diff -u -p -r1.15 -r1.18 --- OpenXM_contrib2/asir2000/plot/ox_plot_xevent.c 2002/07/11 03:34:34 1.15 +++ OpenXM_contrib2/asir2000/plot/ox_plot_xevent.c 2002/07/20 02:28:08 1.18 @@ -45,7 +45,7 @@ * DEVELOPER SHALL HAVE NO LIABILITY IN CONNECTION WITH THE USE, * PERFORMANCE OR NON-PERFORMANCE OF THE SOFTWARE. * - * $OpenXM: OpenXM_contrib2/asir2000/plot/ox_plot_xevent.c,v 1.14 2002/01/30 08:31:34 noro Exp $ + * $OpenXM: OpenXM_contrib2/asir2000/plot/ox_plot_xevent.c,v 1.17 2002/07/12 00:14:40 takayama Exp $ */ #include "ca.h" #include "parse.h" @@ -94,6 +94,7 @@ static struct PlotResources { Pixel ForePixel,BackPixel,DashPixel; char *ForeName,*BackName,*DashName; Boolean Reverse; + Boolean UpsideDown; } PlotResources; #define forePixel PlotResources.ForePixel @@ -103,6 +104,7 @@ static struct PlotResources { #define backName PlotResources.BackName #define dashName PlotResources.DashName #define reverse PlotResources.Reverse +#define upsidedown PlotResources.UpsideDown Cursor create_cursor(); @@ -639,6 +641,7 @@ struct canvas *can; } static XrmOptionDescRec options[] = { +{"-upsidedown","*upsidedown",XrmoptionNoArg,"on"}, {"-reverse","*reverse",XrmoptionNoArg,"on"}, {"-fg","*foreground",XrmoptionSepArg,NULL}, {"-bg","*background",XrmoptionSepArg,NULL}, @@ -647,6 +650,8 @@ static XrmOptionDescRec options[] = { #define offset(name) XtOffset(struct PlotResources *,name) static XtResource resources[] = { +{"upsidedown","UpsideDown",XtRBoolean,sizeof(Boolean), + offset(UpsideDown),XtRBoolean,&upsidedown}, {"reverse","Reverse",XtRBoolean,sizeof(Boolean), offset(Reverse),XtRBoolean,&reverse}, {"foreground","Foreground",XtRString,sizeof(char *), @@ -1144,7 +1149,7 @@ static void generate_psfile(can,fp) colorSize = getColorSizeOfImageForPS(can->width,can->height,image,&tableOfxcolorForPS); color[0] = 0; /* black line */ - generatePS_from_image(fp,image,can->width,can->height,color,colorSize,can,tableOfxcolorForPS); + generatePS_from_image(fp,image,can->width,can->height,color,colorSize,can,tableOfxcolorForPS,upsidedown); }else{ fprintf(stderr,"Cannot print on this system\n"); } @@ -1179,7 +1184,7 @@ struct canvas *can; static struct sm_btree *sm_newNode(unsigned long v); static int sm_insert(struct sm_btree *node,unsigned long v); static int sm_count(struct sm_btree *rootp); -#define MALLOC(a) GC_malloc(a) + struct sm_btree { unsigned long p; struct sm_btree * left; @@ -1218,6 +1223,28 @@ static int sm_count(struct sm_btree *rootp) return (1+sm_count(rootp->left)+sm_count(rootp->right)); } +static int setTableOfxcolorForPS(struct sm_btree *rootp, + struct xcolorForPS *table,int k,int size) +{ + int m; + m = k; + if (rootp == NULL) return; + if (k >= size) { + warning(Can,"internal error of setTableOfxcolorForPS"); + } + if (rootp->left != NULL) { + m = setTableOfxcolorForPS(rootp->left,table,k,size); + } + + (table[m]).pixel = rootp->p; + m++; + if (rootp->right != NULL) { + m = setTableOfxcolorForPS(rootp->right,table,m,size); + } + return m; +} + + static int getColorSizeOfImageForPS(int xsize,int ysize,XImage *image, struct xcolorForPS **tableOfxcolorForPS) { @@ -1225,6 +1252,12 @@ static int getColorSizeOfImageForPS(int xsize,int ysiz int size; struct sm_btree root; struct xcolorForPS *table; + XStandardColormap scm; + Colormap cm; + XColor color; + XColor white; + int screen,i; + root.p = 0; root.left = NULL; root.right=NULL; /* get color size */ @@ -1241,8 +1274,50 @@ static int getColorSizeOfImageForPS(int xsize,int ysiz return 0; } /* Set rgb values standing for the pixel values. - Not implemented. */ + if (setTableOfxcolorForPS(&root,table,0,size) != size) { + warning(Can,"internal error."); + return ; + } + + screen = DefaultScreen(display); + cm = DefaultColormap(display,screen); + /* BUG: it does not work. + if (!XGetStandardColormap(display,RootWindow(display,DefaultScreen(display)),&scm,XA_RGB_DEFAULT_MAP)) { + warning(Can,"failed to open the X Standard Colormap."); + scm.red_max = 0xffff; + scm.green_max = 0xffff; + scm.blue_max = 0xffff; + } + */ + /* Set by hand. */ + scm.red_max = 0xffff; + scm.green_max = 0xffff; + scm.blue_max = 0xffff; + XParseColor(display,cm,"White",&white); + for (i=0; i 1.0) (table[i]).r = 1.0; + if ((table[i]).g > 1.0) (table[i]).g = 1.0; + if ((table[i]).b > 1.0) (table[i]).b = 1.0; + if (color.red == white.red && color.green == white.green + && color.blue == white.blue) { + (table[i]).print = 0; + }else{ + (table[i]).print = 1; + } + } *tableOfxcolorForPS = table; return size;