/*******************************************************************/ /* */ /* HIGH RESOLUTION PLOT */ /* */ /*******************************************************************/ /* $Id: plotX.c,v 1.1.1.1 1999/09/16 13:47:43 karim Exp $ */ #include "pari.h" #include "rect.h" #include "../language/anal.h" void free_graph(void); #ifdef HPPA # ifndef __GNUC__ typedef char *caddr_t; # endif #endif BEGINEXTERN #include #include #include ENDEXTERN static Colormap PARI_Colormap; static XColor *PARI_Colors; static XColor *PARI_ExactColors; static char *PARI_DefaultColors[MAX_COLORS] = { " ", "black", /* Default */ "blue", /* Axes */ "sienna", /* Odd numbered curves in ploth */ "red", /* Curves, or Even numbered curves in ploth */ "cornsilk", "grey", "gainsboro", }; static void PARI_ColorSetUp(Display *display, char **Colors, int n) { static int init_done = 0; int i; if (init_done) return; init_done=1; PARI_Colormap = DefaultColormap(display, 0); PARI_Colors = (XColor *) gpmalloc((n+1) * sizeof(XColor)); PARI_ExactColors = (XColor *) gpmalloc((n+1) * sizeof(XColor)); for (i=1; ierror_code,buf,MAX_BUF); exiterr(buf); return 0; } static int IOerror(Display *d) { char buf[MAX_BUF]; sprintf(buf, "lost display on %s", DisplayString(d)); exiterr(buf); return 0; } static char* zmalloc(size_t x) { return x? gpmalloc(x): NULL; } void rectdraw0(long *w, long *x, long *y, long lw, long do_free) { long *ptx,*pty,*c; long *numpoints[MAX_COLORS],*numtexts[MAX_COLORS]; long *xtexts[MAX_COLORS],*ytexts[MAX_COLORS]; long rcolcnt[MAX_COLORS][ROt_MAX]; long col,i,j,x0,y0,a,b,oldwidth,oldheight,force; long rcnt[ROt_MAX+1]; char **texts[MAX_COLORS]; PariRect *e; RectObj *p1; double xs=1,ys=1; int screen; Display *display; GC gc; Window win; XEvent event; XSizeHints size_hints; XFontStruct *font_info; XSetWindowAttributes attrib; XPoint *points[MAX_COLORS],**lines[MAX_COLORS]; XSegment *seg[MAX_COLORS]; XRectangle *rec[MAX_COLORS]; Atom wm_delete_window, wm_protocols; if (fork()) return; /* parent process returns */ /* child process goes on */ freeall(); /* PARI stack isn't needed anymore, keep rectgraph */ PARI_get_plot(1); display = XOpenDisplay(NULL); font_info = XLoadQueryFont(display, "9x15"); if (!font_info) exiterr("cannot open 9x15 font"); XSetErrorHandler(Xerror); XSetIOErrorHandler(IOerror); PARI_ColorSetUp(display,PARI_DefaultColors,MAX_COLORS); for(col=1;colfid); XMapWindow(display, win); oldwidth = w_width; oldheight = w_height; force = 1; for(;;) { XNextEvent(display, &event); switch(event.type) { case ClientMessage: if (event.xclient.message_type != wm_protocols || event.xclient.data.l[0] != wm_delete_window) break; case ButtonPress: case DestroyNotify: XUnloadFont(display,font_info->fid); XFreeGC(display,gc); #define myfree(x) if (x) free(x) for(col=1;col