home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / x / volume5 / xplot / patch2 next >
Encoding:
Text File  |  1989-09-19  |  6.5 KB  |  243 lines

  1. Path: uunet!island!argv
  2. From: argv@island.uu.net (Dan Heller)
  3. Newsgroups: comp.sources.x
  4. Subject: v05i001: Xplot, Patch2
  5. Message-ID: <1079@island.uu.net>
  6. Date: 19 Sep 89 08:21:25 GMT
  7. Organization: Island Graphics, Marin County, California
  8. Lines: 232
  9. Approved: island!argv@sun.com
  10.  
  11. Submitted-by: uunet!helios.tn.cornell.edu!arthur (Arthur Smith)
  12. Posting-number: Volume 5, Issue 1
  13. Archive-name: xplot/patch2
  14. Patch-To: xplot: Volume 4, Issue 81
  15.  
  16. The patch consists of a shar file containing the patchlevel.h
  17. file which it seems is now required, and a patch file to be
  18. applied to xplot.c. The patches were based on suggestions
  19. or code supplied by a number of people, particularly dana@bellcore.com
  20. who fixed it to work with color. There is a new #define variable
  21. "WideLabel", which determines whether the current point is
  22. moved after a label is drawn. This is not required in the plot(5)
  23. standard, but seems to be assumed by various graphics programs,
  24. particularly by graph(1). The time WAITINTERVAL in microseconds
  25. is intended to put in a delay in the read process, so that
  26. xplot doesn't keep redrawing the screen each time there is a small
  27. gap in data input. If there are any problems, my e-mail address is
  28. below:
  29.  
  30.                 Arthur
  31.  
  32.         arpanet:    arthur@helios.tn.cornell.edu
  33.         bitnet:        arthur@crnlassp
  34.  
  35. # This is a shell archive.  Remove anything before this line,
  36. # then unpack it by saving it in a file and typing "sh file".
  37. #
  38. # Wrapped by helios!arthur on Mon Sep 18 18:27:27 EDT 1989
  39. # Contents:  patchlevel.h xplot.patch2
  40.  
  41. echo x - patchlevel.h
  42. sed 's/^@//' > "patchlevel.h" <<'@//E*O*F patchlevel.h//'
  43. 2.0
  44. @//E*O*F patchlevel.h//
  45. chmod u=rw,g=r,o=r patchlevel.h
  46.  
  47. echo x - xplot.patch2
  48. sed 's/^@//' > "xplot.patch2" <<'@//E*O*F xplot.patch2//'
  49. *** xplot.c.orig    Wed Sep 13 13:56:40 1989
  50. --- xplot.c    Wed Sep 13 13:27:33 1989
  51. ***************
  52. *** 10,15 ****
  53. --- 10,16 ----
  54.   #include <X11/Label.h>
  55.   
  56.   #define LINE 512
  57. + #define WAITINTERVAL 50000
  58.   char buf[LINE];
  59.   char cptr[LINE];
  60.   char *prog;
  61. ***************
  62. *** 21,27 ****
  63.   GC gc;
  64.   XGCValues gcv;
  65.   XtInputId inid;
  66. ! /*XtAppContext app_context; */
  67.   int rwidth = 500, rheight = 500;
  68.   
  69.   short xmin, ymax;
  70. --- 22,29 ----
  71.   GC gc;
  72.   XGCValues gcv;
  73.   XtInputId inid;
  74. ! Pixel fg, bg;
  75. ! XFontStruct *font;
  76.   int rwidth = 500, rheight = 500;
  77.   
  78.   short xmin, ymax;
  79. ***************
  80. *** 211,219 ****
  81.   int argc;
  82.   char **argv;
  83.   {
  84. !     int i, dimset, narg;
  85.   
  86. -     dimset = 0;
  87.       for (i=0;i<argc;i++){
  88.           if (strcmp(argv[i],"-geometry"))
  89.               continue;
  90. --- 213,221 ----
  91.   int argc;
  92.   char **argv;
  93.   {
  94. !     int i, dimset = 0, narg;
  95. !     char *ptr;
  96.   
  97.       for (i=0;i<argc;i++){
  98.           if (strcmp(argv[i],"-geometry"))
  99.               continue;
  100. ***************
  101. *** 226,249 ****
  102.       }
  103.       toplevel = XtInitialize(argv[0], "xplot",NULL, 0, &argc, argv); 
  104.       dpy = XtDisplay(toplevel);
  105. - /*    app_context = XtCreateApplicationContext(); */
  106.   
  107. !     pixmap = XCreatePixmap(dpy,DefaultRootWindow(dpy), rwidth, rheight, 1);
  108. !     gc = XCreateGC(dpy, pixmap, 0L, &gcv);
  109. !     XSetForeground(dpy,gc,1);
  110.   
  111. !     XtSetArg(wargs[0], XtNbitmap, pixmap);
  112. !     narg = 1;
  113.       if (dimset == 0) {
  114. !         XtSetArg(wargs[1], XtNheight, rheight);
  115. !         XtSetArg(wargs[2], XtNwidth, rwidth);
  116. !         narg = 3;
  117.       } 
  118.       child = XtCreateManagedWidget(prog, labelWidgetClass,
  119.                           toplevel, wargs, narg);
  120. - /*    XtCreateManagedWidget(prog, labelWidgetClass, child, wargs, narg); */
  121.       XtRealizeWidget(toplevel);
  122.       widgetwin = XtWindow(child);
  123.       inid = XtAddInput(fileno(instrm), XtInputReadMask, doplot, NULL);
  124.       XtMainLoop();
  125.   }
  126. --- 228,271 ----
  127.       }
  128.       toplevel = XtInitialize(argv[0], "xplot",NULL, 0, &argc, argv); 
  129.       dpy = XtDisplay(toplevel);
  130.   
  131. !     if (!dimset)
  132. !         if (ptr = XGetDefault(dpy,"xplot","geometry")){
  133. !             dimset = 1;
  134. !             rwidth = atoi(ptr);
  135. !             rheight = atoi(1 + index(ptr,'x'));
  136. !         }
  137.   
  138. !     pixmap = XCreatePixmap(dpy,DefaultRootWindow(dpy), rwidth, rheight,
  139. !         DefaultDepth(dpy, DefaultScreen(dpy)));
  140. !     narg = 0;
  141. !     XtSetArg(wargs[narg], XtNbitmap, pixmap); narg++;
  142. !     XtSetArg(wargs[narg], XtNinternalWidth, 0); narg++;
  143. !     XtSetArg(wargs[narg], XtNinternalHeight, 0); narg++;
  144.       if (dimset == 0) {
  145. !         XtSetArg(wargs[narg], XtNheight, rheight); narg++;
  146. !         XtSetArg(wargs[narg], XtNwidth, rwidth); narg++;
  147.       } 
  148.       child = XtCreateManagedWidget(prog, labelWidgetClass,
  149.                           toplevel, wargs, narg);
  150.       XtRealizeWidget(toplevel);
  151.       widgetwin = XtWindow(child);
  152. +     narg = 0;
  153. +     XtSetArg(wargs[narg], XtNbackground, &bg); narg++;
  154. +     XtSetArg(wargs[narg], XtNforeground, &fg); narg++;
  155. +     XtSetArg(wargs[narg], XtNfont, &font); narg++;
  156. +     XtGetValues(child, wargs, narg);
  157. +     gcv.foreground = fg;
  158. +     gcv.background = bg;
  159. +     gcv.font = font->fid;
  160. +     gc = XCreateGC(dpy, pixmap, GCForeground | GCBackground | GCFont,
  161. +              &gcv);
  162. +     erase();
  163.       inid = XtAddInput(fileno(instrm), XtInputReadMask, doplot, NULL);
  164.       XtMainLoop();
  165.   }
  166. ***************
  167. *** 254,262 ****
  168.   {
  169.   /* Wait for button event */
  170.   /* Clear pixmap */
  171. !     XSetForeground(dpy,gc,0);
  172.       XFillRectangle(dpy,pixmap,gc,0,0,rwidth,rheight);
  173. !     XSetForeground(dpy,gc,1);
  174.   }
  175.   
  176.   /* Don't know how I'm going to do this ! */
  177. --- 276,284 ----
  178.   {
  179.   /* Wait for button event */
  180.   /* Clear pixmap */
  181. !     XSetForeground(dpy, gc, bg);
  182.       XFillRectangle(dpy,pixmap,gc,0,0,rwidth,rheight);
  183. !     XSetForeground(dpy, gc, fg);
  184.   }
  185.   
  186.   /* Don't know how I'm going to do this ! */
  187. ***************
  188. *** 266,271 ****
  189. --- 288,296 ----
  190.   {
  191.       XDrawString(dpy,pixmap,gc,MAPX(curpt[0]),MAPY(curpt[1]),s,
  192.               strlen(s) - 1);
  193. + #ifdef WideLabel
  194. +     curpt[0] += (strlen(s)*font->max_bounds.width)/xfactor;
  195. + #endif
  196.   }
  197.   
  198.   line(x1,y1,x2,y2)
  199. ***************
  200. *** 411,418 ****
  201.       if (len > 0)
  202.           bcopy(curp, cptr, len);
  203.       if ((lenp = fread(cptr+len, 1, LINE - len, strm)) == 0){
  204. !         endinp = 1;
  205. !         return 0;
  206.       }
  207.       len += lenp;
  208.       curp = cptr;
  209. --- 436,446 ----
  210.       if (len > 0)
  211.           bcopy(curp, cptr, len);
  212.       if ((lenp = fread(cptr+len, 1, LINE - len, strm)) == 0){
  213. !         usleep(WAITINTERVAL); /* Wait in case stuff is on the way */
  214. !         if ((lenp = fread(cptr+len, 1, LINE - len, strm)) == 0){
  215. !             endinp = 1;
  216. !             return 0;
  217. !         }
  218.       }
  219.       len += lenp;
  220.       curp = cptr;
  221. @//E*O*F xplot.patch2//
  222. chmod u=rw,g=r,o=r xplot.patch2
  223.  
  224. echo Inspecting for damage in transit...
  225. temp=/tmp/shar$$; dtemp=/tmp/.shar$$
  226. trap "rm -f $temp $dtemp; exit" 0 1 2 3 15
  227. cat > $temp <<\!!!
  228.        1       1       4 patchlevel.h
  229.      177     564    4376 xplot.patch2
  230.      178     565    4380 total
  231. !!!
  232. wc  patchlevel.h xplot.patch2 | sed 's=[^ ]*/==' | diff -b $temp - >$dtemp
  233. if [ -s $dtemp ]
  234. then echo "Ouch [diff of wc output]:" ; cat $dtemp
  235. else echo "No problems found."
  236. fi
  237. exit 0
  238.