| 12 |
|
|
| 13 |
|
#include "plot.h" |
| 14 |
|
|
| 15 |
+ |
#include "string.h" |
| 16 |
+ |
|
| 17 |
|
#undef TRUE |
| 18 |
|
|
| 19 |
|
#undef FALSE |
| 20 |
|
|
| 21 |
|
#include <X11/Xlib.h> |
| 22 |
|
|
| 23 |
+ |
extern void replay(int xmin, int ymin, int xmax, int ymax); |
| 24 |
|
|
| 25 |
|
#define BORWIDTH 5 |
| 26 |
|
|
| 27 |
|
#define BlackPix BlackPixel(dpy,0 ) |
| 28 |
|
#define WhitePix WhitePixel(dpy,0 ) |
| 29 |
|
|
| 30 |
< |
#define mapx(x) CONV(x,dxsize) |
| 31 |
< |
#define mapy(y) CONV((XYSIZE-1)-(y),dysize) |
| 30 |
> |
#define mapx(x) CONV(x,dxsiz) |
| 31 |
> |
#define mapy(y) CONV((XYSIZE-1)-(y),dysiz) |
| 32 |
|
|
| 33 |
|
#define MAXVERT 128 |
| 34 |
|
|
| 82 |
|
int curlinetype; /* current line style */ |
| 83 |
|
XGCValues gcval; |
| 84 |
|
int pixel[4]; |
| 85 |
< |
int dxsize, dysize; /* window size */ |
| 85 |
> |
int dxsiz, dysiz; /* window size */ |
| 86 |
|
int debug = False; /* use XSynchronize if true */ |
| 87 |
|
|
| 88 |
+ |
static void |
| 89 |
+ |
adjustsize() |
| 90 |
+ |
{ |
| 91 |
+ |
if (dxsiz > dysiz) |
| 92 |
+ |
dxsiz = dysiz; |
| 93 |
+ |
else |
| 94 |
+ |
dysiz = dxsiz; |
| 95 |
+ |
} |
| 96 |
+ |
|
| 97 |
+ |
|
| 98 |
+ |
void |
| 99 |
|
init(name, geom) /* initialize window */ |
| 100 |
|
char *name; |
| 101 |
|
char *geom; |
| 103 |
|
char defgeom[32]; |
| 104 |
|
XColor cdef,dum; |
| 105 |
|
XEvent evnt; |
| 92 |
– |
int dummy; |
| 106 |
|
|
| 107 |
|
curfont = curfill = curcol = -1; |
| 108 |
|
curlinetype = 0; |
| 114 |
|
if (debug) |
| 115 |
|
(void) XSynchronize(dpy, True); |
| 116 |
|
|
| 117 |
< |
dxsize = DisplayWidth(dpy,0) - 2*BORWIDTH-4; |
| 118 |
< |
dysize = DisplayHeight(dpy,0) - 2*BORWIDTH-26; |
| 106 |
< |
|
| 107 |
< |
/* temporary */ |
| 108 |
< |
dxsize = dxsize = 800; |
| 117 |
> |
dxsiz = DisplayWidth(dpy,0) - 2*BORWIDTH-4; |
| 118 |
> |
dysiz = DisplayHeight(dpy,0) - 2*BORWIDTH-100; |
| 119 |
|
adjustsize(); |
| 120 |
|
|
| 121 |
< |
sprintf(defgeom, "=%dx%d+2+25", dxsize, dysize); |
| 121 |
> |
sprintf(defgeom, "=%dx%d+2+25", dxsiz, dysiz); |
| 122 |
|
/* XUseGeometry(dpy,0,geom,defgeom,BORWIDTH,100,100,100,100, |
| 123 |
< |
&xoff,&yoff,&dxsize,&dysize); */ |
| 123 |
> |
&xoff,&yoff,&dxsiz,&dysiz); */ |
| 124 |
|
gc = DefaultGC(dpy,0); /* get default gc */ |
| 125 |
|
cmap = DefaultColormap(dpy,0); /* and colormap */ |
| 126 |
|
|
| 127 |
< |
wind = XCreateSimpleWindow(dpy,DefaultRootWindow(dpy),0,0,dxsize,dysize, |
| 127 |
> |
wind = XCreateSimpleWindow(dpy,DefaultRootWindow(dpy),0,0,dxsiz,dysiz, |
| 128 |
|
BORWIDTH,BlackPix,WhitePix); |
| 129 |
|
if (wind == 0) |
| 130 |
|
error(SYSTEM, "can't create window"); |
| 163 |
|
if (evnt.type == ConfigureNotify) /* wait for first ConfigureNotify */ |
| 164 |
|
break; |
| 165 |
|
} |
| 166 |
< |
dxsize = evnt.xconfigure.width; |
| 167 |
< |
dysize = evnt.xconfigure.height; |
| 166 |
> |
dxsiz = evnt.xconfigure.width; |
| 167 |
> |
dysiz = evnt.xconfigure.height; |
| 168 |
|
adjustsize(); |
| 169 |
|
while (1) |
| 170 |
|
{ |
| 174 |
|
} |
| 175 |
|
} |
| 176 |
|
|
| 167 |
– |
adjustsize() |
| 168 |
– |
{ |
| 169 |
– |
if (dxsize > dysize) |
| 170 |
– |
dxsize = dysize; |
| 171 |
– |
else |
| 172 |
– |
dysize = dxsize; |
| 173 |
– |
} |
| 177 |
|
|
| 178 |
|
void |
| 179 |
|
endpage() /* end of this graph */ |
| 187 |
|
XNextEvent(dpy, &evnt); |
| 188 |
|
switch (evnt.type) { |
| 189 |
|
case ConfigureNotify: |
| 190 |
< |
dxsize = evnt.xconfigure.width; |
| 191 |
< |
dysize = evnt.xconfigure.height; |
| 190 |
> |
dxsiz = evnt.xconfigure.width; |
| 191 |
> |
dysiz = evnt.xconfigure.height; |
| 192 |
|
adjustsize(); |
| 193 |
|
break; |
| 194 |
|
case Expose: |
| 195 |
< |
replay((int)((long)XYSIZE*evnt.xexpose.x/dxsize), |
| 196 |
< |
(int)((long)XYSIZE*(dysize-evnt.xexpose.y-evnt.xexpose.height)/dysize), |
| 197 |
< |
(int)((long)XYSIZE*(evnt.xexpose.x+evnt.xexpose.width)/dxsize), |
| 198 |
< |
(int)((long)XYSIZE*(dysize-evnt.xexpose.y)/dysize)); |
| 195 |
> |
replay((int)((long)XYSIZE*evnt.xexpose.x/dxsiz), |
| 196 |
> |
(int)((long)XYSIZE*(dysiz-evnt.xexpose.y-evnt.xexpose.height)/dysiz), |
| 197 |
> |
(int)((long)XYSIZE*(evnt.xexpose.x+evnt.xexpose.width)/dxsiz), |
| 198 |
> |
(int)((long)XYSIZE*(dysiz-evnt.xexpose.y)/dysiz)); |
| 199 |
|
break; |
| 200 |
|
case ButtonPress: |
| 201 |
|
quit = True; |
| 263 |
|
col = p->arg0 & 03; /* color */ |
| 264 |
|
|
| 265 |
|
ps = WIDTH((p->arg0 >> 2) & 03); |
| 266 |
< |
pw = CONV((ps)/2, dxsize); |
| 266 |
> |
pw = CONV((ps)/2, dxsiz); |
| 267 |
|
|
| 268 |
|
x1 = mapx(p->xy[XMN]); |
| 269 |
|
x2 = mapx(p->xy[XMX]); |
| 300 |
|
} |
| 301 |
|
|
| 302 |
|
|
| 303 |
+ |
void |
| 304 |
+ |
pXFlush() |
| 305 |
+ |
{ |
| 306 |
+ |
XFlush(dpy); |
| 307 |
+ |
} |
| 308 |
+ |
|
| 309 |
+ |
|
| 310 |
|
#ifdef nyet |
| 311 |
|
|
| 312 |
|
static void |
| 313 |
|
fill(xmin,ymin,xmax,ymax,pm) |
| 314 |
|
int xmin,ymin,xmax,ymax; |
| 315 |
|
Pixmap pm; |
| 316 |
< |
{ |
| 316 |
> |
{ |
| 317 |
|
if (pm != 0 && curpat != pm) |
| 318 |
|
{ |
| 319 |
|
XSetTile(dpy, gc, pm); |
| 320 |
|
curpat = pm; |
| 321 |
|
} |
| 322 |
|
XFillRectangle(dpy, wind, gc, xmin, ymin, xmax-xmin+1, ymax-ymin+1); |
| 323 |
< |
} |
| 323 |
> |
} |
| 324 |
|
|
| 325 |
+ |
|
| 326 |
+ |
void |
| 327 |
|
fillrect(p) /* fill a rectangle */ |
| 328 |
|
|
| 329 |
|
register PRIMITIVE *p; |
| 343 |
|
|
| 344 |
|
|
| 345 |
|
|
| 346 |
+ |
void |
| 347 |
|
filltri(p) /* fill a triangle */ |
| 348 |
|
|
| 349 |
|
register PRIMITIVE *p; |
| 391 |
|
} |
| 392 |
|
|
| 393 |
|
|
| 394 |
< |
|
| 394 |
> |
vpod |
| 395 |
|
xform(xp, yp, p) /* transform a point according to p */ |
| 396 |
|
|
| 397 |
|
register int *xp, *yp; |
| 425 |
|
} |
| 426 |
|
|
| 427 |
|
|
| 428 |
< |
|
| 428 |
> |
void |
| 429 |
|
fillpoly(p) /* fill a polygon */ |
| 430 |
|
|
| 431 |
|
register PRIMITIVE *p; |