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

Comparing ray/src/rt/x10.c (file contents):
Revision 1.23 by greg, Tue Jan 30 11:37:48 1990 UTC vs.
Revision 1.27 by greg, Mon Mar 5 09:14:15 1990 UTC

# Line 29 | Line 29 | static char SCCSid[] = "$SunId$ LBL";
29   #define BORWIDTH        5               /* border width */
30   #define COMHEIGHT       (COMLH*COMCH)   /* command line height (pixels) */
31   #define MINWIDTH        (32*COMCW)      /* minimum graphics window width */
32 < #define MINHEIGHT       64              /* minimum graphics window height */
32 > #define MINHEIGHT       MINWIDTH                /* minimum graphics window height */
33  
34   #define COMFN           "8x13"          /* command line font name */
35   #define COMLH           3               /* number of command lines */
36   #define COMCW           8               /* approx. character width (pixels) */
37   #define COMCH           13              /* approx. character height (pixels) */
38  
39 #ifndef WFLUSH
40 #define WFLUSH          30              /* flush after this many rays */
41 #endif
42
43 #define  checkinp()     while (XPending() > 0) getevent()
44
39   #define  levptr(etype)  ((etype *)&thisevent)
40  
41   static XEvent  thisevent;               /* current event */
# Line 55 | Line 49 | static Window  gwind = 0;              /* our graphics window */
49  
50   static Cursor  pickcursor = 0;          /* cursor used for picking */
51  
52 < static int  gwidth = 0;                 /* graphics window width */
59 < static int  gheight = 0;                /* graphics window height */
52 > static int  gwidth, gheight;            /* graphics window size */
53  
54   static TEXTWIND  *comline = NULL;       /* our command line */
55  
# Line 69 | Line 62 | extern char  *malloc(), *getcombuf();
62   extern char  *progname;
63  
64   int  x_close(), x_clear(), x_paintr(), x_errout(),
65 <                x_getcur(), x_comout(), x_comin();
65 >                x_getcur(), x_comout(), x_comin(), x_flush();
66  
67   static struct driver  x_driver = {
68          x_close, x_clear, x_paintr, x_getcur,
69 <        x_comout, x_comin, 1.0
69 >        x_comout, x_comin, x_flush, 1.0
70   };
71  
72  
# Line 111 | Line 104 | char  *name, *id;
104                  return(NULL);
105          }
106          XStoreName(gwind, id);
114        XMapWindow(gwind);
107          XSelectInput(gwind, KeyPressed|ButtonPressed|
108                          ExposeWindow|ExposeRegion|UnmapWindow);
109 <        x_driver.xsiz = mainframe.width;
110 <        x_driver.ysiz = mainframe.height-COMHEIGHT;
109 >        gwidth = mainframe.width;
110 >        gheight = mainframe.height-COMHEIGHT;
111 >        x_driver.xsiz = gwidth < MINWIDTH ? MINWIDTH : gwidth;
112 >        x_driver.ysiz = gheight < MINHEIGHT ? MINHEIGHT : gheight;
113          x_driver.inpready = 0;
114          cmdvec = x_comout;                      /* set error vectors */
115          if (wrnvec != NULL)
# Line 139 | Line 133 | x_close()                      /* close our display */
133          if (gwind != 0) {
134                  XDestroyWindow(gwind);
135                  gwind = 0;
142                gwidth = gheight = 0;
136          }
137          XFreeCursor(pickcursor);
138          freepixels();
# Line 152 | Line 145 | static
145   x_clear(xres, yres)                     /* clear our display */
146   int  xres, yres;
147   {
155        if (xres < MINWIDTH)
156                xres = MINWIDTH;
157        if (yres < MINHEIGHT)
158                yres = MINHEIGHT;
148          if (xres != gwidth || yres != gheight) {        /* new window */
149                  if (comline != NULL)
150                          xt_close(comline);
# Line 174 | Line 163 | int  xres, yres;
163                  stderr_v("cannot allocate colors\n");
164          else
165                  new_ctab(ncolors);
166 +
167 +        XMapWindow(gwind);                      /* make sure it's mapped */
168          XSync(1);                               /* discard input */
169          return;
170   }
# Line 184 | Line 175 | x_paintr(col, xmin, ymin, xmax, ymax)          /* fill a recta
175   COLOR  col;
176   int  xmin, ymin, xmax, ymax;
177   {
187        extern long  nrays;             /* global ray count */
178          extern int  xnewcolr();         /* pixel assignment routine */
189        static long  lastflush = 0;     /* ray count at last flush */
179  
180          if (ncolors > 0) {
181                  XPixSet(gwind, xmin, gheight-ymax, xmax-xmin, ymax-ymin,
182                                  pixval[get_pixel(col, xnewcolr)]);
183          }
195        if (nrays - lastflush >= WFLUSH) {
196                if (ncolors <= 0)       /* output necessary for death */
197                        XPixSet(gwind,0,0,1,1,BlackPixel);
198                checkinp();
199                lastflush = nrays;
200        }
184   }
185  
186  
187   static
188 + x_flush()                       /* flush output */
189 + {
190 +        if (ncolors <= 0)       /* output necessary for death */
191 +                XPixSet(gwind,0,0,1,1,BlackPixel);
192 +        while (XPending() > 0)
193 +                getevent();
194 +
195 + }
196 +
197 +
198 + static
199   x_comin(inp, prompt)            /* read in a command line */
200   char  *inp, *prompt;
201   {
# Line 222 | Line 216 | static
216   x_comout(out)                   /* output a string to command line */
217   char  *out;
218   {
219 <        if (comline != NULL)
220 <                xt_puts(out, comline);
221 <        XFlush();
219 >        if (comline == NULL)
220 >                return;
221 >        xt_puts(out, comline);
222 >        if (out[strlen(out)-1] == '\n')
223 >                XFlush();
224   }
225  
226  
# Line 232 | Line 228 | static
228   x_errout(msg)                   /* output an error message */
229   char  *msg;
230   {
235        x_comout(msg);
231          stderr_v(msg);          /* send to stderr also! */
232 +        x_comout(msg);
233   }
234  
235  
# Line 359 | Line 355 | register XExposeEvent  *eexp;
355          }
356                                          /* check for change in size */
357          if (eexp->width != gwidth || eexp->height-COMHEIGHT != gheight) {
358 <                x_driver.xsiz = eexp->width;
359 <                x_driver.ysiz = eexp->height-COMHEIGHT;
358 >                gwidth = eexp->width;
359 >                gheight = eexp->height-COMHEIGHT;
360 >                x_driver.xsiz = gwidth < MINWIDTH ? MINWIDTH : gwidth;
361 >                x_driver.ysiz = gheight < MINHEIGHT ? MINHEIGHT : gheight;
362                  strcpy(getcombuf(&x_driver), "new\n");
363                  return;
364          }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines