49 #include <X11/Xutil.h>
125 XDrawLine (
wds[wn].dspy,
wds[wn].wndw,
wds[wn].gc,
wds[wn].led,
127 XDrawLine (
wds[wn].dspy,
wds[wn].wndw,
wds[wn].gc,
wds[wn].led,
129 XDrawLine (
wds[wn].dspy,
wds[wn].wndw,
wds[wn].gc,
wds[wn].red,
131 XDrawLine (
wds[wn].dspy,
wds[wn].wndw,
wds[wn].gc,
wds[wn].led,
141 wds[wn].indx,
wds[wn].mode);
145 wds[wn].indx,
wds[wn].mode);
148 XDrawLines (
wds[wn].dspy,
wds[wn].wndw,
wds[wn].gc1,
wds[wn].xye,
149 wds[wn].indx,
wds[wn].mode);
150 XDrawLines (
wds[wn].dspy,
wds[wn].wndw,
wds[wn].gc2,
wds[wn].xys,
151 wds[wn].indx,
wds[wn].mode);
152 XDrawLines (
wds[wn].dspy,
wds[wn].wndw,
wds[wn].gc3,
wds[wn].ydif,
153 wds[wn].indx,
wds[wn].mode);
156 XDrawLines (
wds[wn].dspy,
wds[wn].wndw,
wds[wn].gc1,
wds[wn].xye,
157 wds[wn].indx,
wds[wn].mode);
160 XDrawLines (
wds[wn].dspy,
wds[wn].wndw,
wds[wn].gc2,
wds[wn].xys,
161 wds[wn].indx,
wds[wn].mode);
164 XFlush (
wds[wn].dspy);
176 list = (
struct xarry *) malloc (
sizeof (
struct xarry));
209 for (i = 1; i < indx; i++)
229 for (i = 1; i < indx; i++)
246 differnce (XPoint * xy1, XPoint * xy2,
int indx, XPoint * ydif,
int yzer)
252 for (i = 0; i < indx; ++i)
254 ydif[i].x = xy1[i].x;
255 ydif[i].y = (xy1[i].y - xy2[i].y) + yzer;
266 pixary (
float *
y,
float min,
float step,
int n, XPoint * xy,
float ymax,
273 int i = 0, xer, xel, yet, yeb;
275 struct xarry *xlist, *list;
284 xlist =
xnew (xlist);
287 for (i = 0; i <= n; i++)
289 (*list).
x = min + (i * step);
291 (*list).next =
xnew ((*list).next);
301 while (xlist != NULL)
304 ((xer - xel) / (
wds[wn].xmax - xmin)) * ((*xlist).x - xmin) + xel;
306 xy[i].y = (yeb - yet) / (ymin - ymax) * (y[i] - ymax) + yet;
308 xlist = (*xlist).
next;
323 float y1max, y1min, y2max, y2min;
331 wds[wn].
ymax = (y1max > y2max) ? y1max : y2max;
332 wds[wn].
ymin = (y1min < y2min) ? y1min : y2min;
335 wds[wn].xye,
wds[wn].ymax,
wds[wn].ymin, wn);
338 wds[wn].xys,
wds[wn].ymax,
wds[wn].ymin, wn);
351 calcpt (
int xpt,
int ypt,
float *xpt1,
float *ypt1,
int wn)
353 int xer, xel, yet, yeb;
378 xypts[1].y = ypt + 1;
380 xypts[2].y = ypt - 1;
381 xypts[3].x = xpt + 1;
383 xypts[4].x = xpt - 1;
389 getstr (
char *pltstr,
float xpt,
float ypt)
391 char cxstr[10], cystr[10];
393 sprintf (cxstr,
"%0.2f", xpt);
394 sprintf (cystr,
"%0.2e", ypt);
396 strcpy (pltstr,
"( ");
397 strcat (pltstr, cxstr);
398 strcat (pltstr,
", ");
399 strcat (pltstr, cystr);
400 strcat (pltstr,
" ) ");
410 XWindowAttributes myattribs;
413 float xpt1, xpt2, xptd, ypt1, ypt2, yptd;
414 int xpt, xptr, ypt, yptr, xlow, ylow;
415 XPoint pts1[5], pts2[5];
418 XNextEvent (
wds[wn].dspy, &myevent);
420 switch (myevent.type)
425 if (myevent.xexpose.count == 0)
427 XGetWindowAttributes (
wds[wn].dspy,
wds[wn].wndw, &myattribs);
429 wds[wn].
ny = myattribs.height;
430 wds[wn].
nx = myattribs.width;
448 XRefreshKeyboardMapping ((XMappingEvent *) & myevent);
454 if (myevent.xbutton.button == 1)
456 xpt = myevent.xbutton.x;
457 ypt = myevent.xbutton.y;
459 calcpt (xpt, ypt, &xpt1, &ypt1, wn);
462 XDrawPoints (
wds[wn].dspy,
wds[wn].wndw,
wds[wn].gc, pts1, 5,
465 if (myevent.xbutton.button == 3)
467 xpt = myevent.xbutton.x;
468 ypt = myevent.xbutton.y;
470 calcpt (xpt, ypt, &xpt1, &ypt1, wn);
473 getstr (cpltstr, xpt1, ypt1);
475 XDrawPoints (
wds[wn].dspy,
wds[wn].wndw,
wds[wn].gc, pts1, 5,
477 if ((xpt + (strlen (cpltstr) * 6)) <
wds[wn].nx)
479 XDrawString (
wds[wn].dspy,
wds[wn].wndw,
wds[wn].gc, xpt + 6,
480 ypt + 3, cpltstr, strlen (cpltstr));
481 else if ((xpt - (strlen (cpltstr) * 6)) > 0)
483 XDrawString (
wds[wn].dspy,
wds[wn].wndw,
wds[wn].gc, xpt -
484 (strlen (cpltstr) * 6) + 6, ypt + 3, cpltstr,
487 else if ((ypt + 10) >
wds[wn].ny)
489 XDrawString (
wds[wn].dspy,
wds[wn].wndw,
wds[wn].gc, xpt -
490 (strlen (cpltstr) * 6) / 2 + 6,
491 ypt + 10, cpltstr, strlen (cpltstr));
495 XDrawString (
wds[wn].dspy,
wds[wn].wndw,
wds[wn].gc, xpt -
496 (strlen (cpltstr) * 6) / 2 + 6,
497 ypt - 10, cpltstr, strlen (cpltstr));
503 if (myevent.xbutton.button == 1)
505 xptr = myevent.xbutton.x;
506 yptr = myevent.xbutton.y;
508 xlow = (xpt - xptr) / 2 + xptr;
509 ylow = (ypt - yptr) / 2 + yptr;
511 calcpt (xptr, yptr, &xpt2, &ypt2, wn);
517 getstr (cpltstr, xptd, yptd);
519 XDrawPoints (
wds[wn].dspy,
wds[wn].wndw,
wds[wn].gc, pts2, 5,
522 if ((xlow + 250) <
wds[wn].nx)
523 XDrawString (
wds[wn].dspy,
wds[wn].wndw,
wds[wn].gc, xlow + 6,
524 ylow + 3, cpltstr, strlen (cpltstr));
525 else if ((xlow - 250) > 0)
526 XDrawString (
wds[wn].dspy,
wds[wn].wndw,
wds[wn].gc, xlow -
527 (strlen (cpltstr) * 6) + 6,
528 ylow + 3, cpltstr, strlen (cpltstr));
529 else if ((ylow + 10) >
wds[wn].ny)
530 XDrawString (
wds[wn].dspy,
wds[wn].wndw,
wds[wn].gc, xlow -
531 (strlen (cpltstr) * 6) / 2 + 6,
532 ylow + 10, cpltstr, strlen (cpltstr));
534 XDrawString (
wds[wn].dspy,
wds[wn].wndw,
wds[wn].gc, xlow -
535 (strlen (cpltstr) * 6) / 2 + 6,
536 ylow - 10, cpltstr, strlen (cpltstr));
542 i = XLookupString ((XKeyEvent *) & myevent, txt, 10, &mykey, 0);
585 XFlush (
wds[wn].dspy);
593 XColor orng, grn, mgnt, blk, wht;
595 Status resultb, resultba, resultw, resultwa;
596 Status result1a, result1, result2a;
597 Status result2, result3a, result3;
598 char *name1, *name2, *name3, *nameb, *namew;
601 if (getenv (
"DISPLAY"))
612 XFreeGC (
wds[wn].dspy,
wds[wn].gc);
613 XFreeGC (
wds[wn].dspy,
wds[wn].gc1);
614 XFreeGC (
wds[wn].dspy,
wds[wn].gc2);
615 XFreeGC (
wds[wn].dspy,
wds[wn].gc3);
616 XDestroyWindow (
wds[wn].dspy,
wds[wn].wndw);
617 XCloseDisplay (
wds[wn].dspy);
623 printf (
"Numwndws = %d\n",
numwndws);
629 wds[wn].
dspy = XOpenDisplay (
"");
631 wds[wn].
map = XDefaultColormap (
wds[wn].dspy,
wds[wn].scrn);
633 wds[wn].
mode = CoordModeOrigin;
636 printf (
"Getwndws: Wds[%d].dspy = %d\n", wn,
wds[wn].dspy);
642 myhint.y = (wn - 1) * 400;
646 myhint.x = (wn - 1) * 400;
650 myhint.flags = PPosition | PSize;
653 wds[wn].
wndw = XCreateSimpleWindow (
wds[wn].dspy,
654 DefaultRootWindow (
wds[wn].
657 myhint.width, myhint.height, 5,
659 XSetStandardProperties (
wds[wn].dspy,
wds[wn].wndw, title[wn - 1],
660 title[wn - 1], None, NULL, 0, &myhint);
670 result1 = XParseColor (
wds[wn].dspy,
wds[wn].map, name1, &orng);
671 result2 = XParseColor (
wds[wn].dspy,
wds[wn].map, name2, &grn);
672 result3 = XParseColor (
wds[wn].dspy,
wds[wn].map, name3, &mgnt);
673 resultb = XParseColor (
wds[wn].dspy,
wds[wn].map, nameb, &blk);
674 resultw = XParseColor (
wds[wn].dspy,
wds[wn].map, namew, &wht);
677 result1a = XAllocColor (
wds[wn].dspy,
wds[wn].map, &orng);
678 result2a = XAllocColor (
wds[wn].dspy,
wds[wn].map, &grn);
679 result3a = XAllocColor (
wds[wn].dspy,
wds[wn].map, &mgnt);
680 resultba = XAllocColor (
wds[wn].dspy,
wds[wn].map, &blk);
681 resultwa = XAllocColor (
wds[wn].dspy,
wds[wn].map, &wht);
684 myfont = XLoadFont (
wds[wn].dspy,
"6x13");
688 wds[wn].
gc = XCreateGC (
wds[wn].dspy,
wds[wn].wndw, 0, 0);
690 XSetBackground (
wds[wn].dspy,
wds[wn].gc, blk.pixel);
692 XSetForeground (
wds[wn].dspy,
wds[wn].gc, wht.pixel);
694 XSetFont (
wds[wn].dspy,
wds[wn].gc, myfont);
698 if ((result1 != 0) && (result1a != 0))
701 wds[wn].
gc1 = XCreateGC (
wds[wn].dspy,
wds[wn].wndw, 0, 0);
703 XSetBackground (
wds[wn].dspy,
wds[wn].gc1, blk.pixel);
705 XSetForeground (
wds[wn].dspy,
wds[wn].gc1, orng.pixel);
710 wds[wn].
gc1 = XCreateGC (
wds[wn].dspy,
wds[wn].wndw, 0, 0);
712 XSetBackground (
wds[wn].dspy,
wds[wn].gc1, blk.pixel);
714 XSetForeground (
wds[wn].dspy,
wds[wn].gc1, wht.pixel);
719 if ((result2 != 0) && (result2a != 0))
721 wds[wn].
gc2 = XCreateGC (
wds[wn].dspy,
wds[wn].wndw, 0, 0);
723 XSetBackground (
wds[wn].dspy,
wds[wn].gc2, blk.pixel);
725 XSetForeground (
wds[wn].dspy,
wds[wn].gc2, grn.pixel);
730 wds[wn].
gc2 = XCreateGC (
wds[wn].dspy,
wds[wn].wndw, 0, 0);
732 XSetBackground (
wds[wn].dspy,
wds[wn].gc2, blk.pixel);
734 XSetForeground (
wds[wn].dspy,
wds[wn].gc2, wht.pixel);
739 if ((result3 != 0) && (result3a != 0))
741 wds[wn].
gc3 = XCreateGC (
wds[wn].dspy,
wds[wn].wndw, 0, 0);
743 XSetBackground (
wds[wn].dspy,
wds[wn].gc3, blk.pixel);
745 XSetForeground (
wds[wn].dspy,
wds[wn].gc3, mgnt.pixel);
750 wds[wn].
gc3 = XCreateGC (
wds[wn].dspy,
wds[wn].wndw, 0, 0);
752 XSetBackground (
wds[wn].dspy,
wds[wn].gc3, blk.pixel);
754 XSetForeground (
wds[wn].dspy,
wds[wn].gc3, wht.pixel);
759 XSelectInput (
wds[wn].dspy,
wds[wn].wndw,
762 ButtonPressMask | ButtonReleaseMask |
763 OwnerGrabButtonMask | KeyPressMask | ExposureMask);
766 XMapRaised (
wds[wn].dspy,
wds[wn].wndw);
780 printf (
"Getwndws: End of for, wds[%d].dspy = %d\n", wn,
797 for (i = 0; i <
wds[wn].
indx; ++i)
799 wds[wn].
ye[i] = y1[i];
800 wds[wn].
ys[i] = (y1[i] - y2[i]);
806 double *xstep1,
int *indx1,
int *wnum)
812 XWindowAttributes myattribs;
816 printf (
"Wnum = %d\n", *wnum);
817 printf (
"Fstplt: Before setting variables to parameters\n");
824 printf (
"After wn, wn = %d, before indx\n", wn);
829 printf (
"After indx, before xmin\n");
834 printf (
"After xmin, before xstep\n");
839 printf (
"Before XGetWindowAttributes, dspy = %d, wndw = %d\n",
840 wds[wn].dspy,
wds[wn].wndw);
843 XGetWindowAttributes (
wds[wn].dspy,
wds[wn].wndw, &myattribs);
846 wds[wn].
ny = myattribs.height;
847 wds[wn].
nx = myattribs.width;
868 while (XEventsQueued (
wds[wn].dspy, QueuedAfterReading) > 0)
884 XFreeGC (
wds[wn].dspy,
wds[wn].gc);
885 XFreeGC (
wds[wn].dspy,
wds[wn].gc1);
886 XFreeGC (
wds[wn].dspy,
wds[wn].gc2);
887 XFreeGC (
wds[wn].dspy,
wds[wn].gc3);
888 XDestroyWindow (
wds[wn].dspy,
wds[wn].wndw);
889 XCloseDisplay (
wds[wn].dspy);
int findzero(int wn, float ymax, float ymin)
void FORTRAN() fstplt(double *y1, double *y2, double *xmin1, double *xstep1, int *indx1, int *wnum)
float findmin(float *ary, int indx)
double complex, dimension(mxdim), save y
void pixary(float *y, float min, float step, int n, XPoint *xy, float ymax, float ymin, int wn)
struct wstruct wds[MAX_WINDOWS+1]
double precision, pointer, save bed
void FORTRAN() getwndws(int *n, word *title)
void calcpt(int xpt, int ypt, float *xpt1, float *ypt1, int wn)
struct xarry * xnew(struct xarry *list)
void xdump(struct xarry *list)
void getstr(char *pltstr, float xpt, float ypt)
void differnce(XPoint *xy1, XPoint *xy2, int indx, XPoint *ydif, int yzer)
void putary(double *y1, double *y2, int wn)
void setxpts(XPoint *xypts, int xpt, int ypt)
void FORTRAN() shtwndws()
integer, pointer, save mode
float findmax(float *ary, int indx)