ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/meta/x11plot.c
(Generate patch)

Comparing ray/src/meta/x11plot.c (file contents):
Revision 1.1 by greg, Sat Feb 22 02:07:26 2003 UTC vs.
Revision 1.5 by greg, Mon Nov 18 22:12:32 2019 UTC

# Line 12 | Line 12 | static const char      RCSid[] = "$Id$";
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  
# Line 79 | Line 82 | int    curcol;                 /* current color */
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;
# Line 89 | Line 103 | 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;
# Line 101 | Line 114 | char  *geom;
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");
# Line 153 | Line 163 | char  *geom;
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          {
# Line 164 | Line 174 | char  *geom;
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 */
180   {
181      XEvent  evnt;
# Line 183 | Line 187 | 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;
# Line 204 | Line 208 | endpage()              /* end of this graph */
208  
209  
210  
211 + void
212   printstr(p)             /* output a string */
213  
214   register PRIMITIVE  *p;
# Line 243 | Line 248 | register PRIMITIVE  *p;
248  
249  
250  
251 + void
252   plotlseg(p)             /* plot a line segment */
253  
254   register PRIMITIVE  *p;
# Line 257 | Line 263 | register PRIMITIVE  *p;
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]);
# Line 294 | Line 300 | register PRIMITIVE  *p;
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 + {
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 + }
324 +
325 +
326 + void
327   fillrect(p)                     /* fill a rectangle */
328  
329   register PRIMITIVE  *p;
# Line 315 | Line 343 | register PRIMITIVE  *p;
343  
344  
345  
346 + void
347   filltri(p)                      /* fill a triangle */
348  
349   register PRIMITIVE  *p;
# Line 362 | Line 391 | 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;
# Line 396 | Line 425 | register PRIMITIVE  *p;
425   }
426  
427  
428 <
428 > void
429   fillpoly(p)                     /* fill a polygon */
430  
431   register PRIMITIVE  *p;
# Line 449 | Line 478 | register PRIMITIVE  *p;
478  
479   }
480  
452 fill(xmin,ymin,xmax,ymax,pm)
453 int xmin,ymin,xmax,ymax;
454 Pixmap pm;
455        {
456        if (pm != 0 && curpat != pm)
457                {
458                XSetTile(dpy, gc, pm);
459                curpat = pm;
460                }
461        XFillRectangle(dpy, wind, gc, xmin, ymin, xmax-xmin+1, ymax-ymin+1);
462        }
463
481   #else
482  
483 < filltri() {}
484 < fillpoly() {}
485 < fillrect() {}
469 <
483 > void filltri(PRIMITIVE *p) {}
484 > void fillpoly(PRIMITIVE *p) {}
485 > void fillrect(PRIMITIVE *p) {}
486  
487   #endif

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines