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

Comparing ray/src/util/xglaresrc.c (file contents):
Revision 1.9 by greg, Wed Jul 31 15:28:03 1991 UTC vs.
Revision 2.8 by greg, Tue Nov 11 16:24:06 2003 UTC

# Line 1 | Line 1
1 /* Copyright (c) 1991 Regents of the University of California */
2
1   #ifndef lint
2 < static char SCCSid[] = "$SunId$ LBL";
2 > static const char       RCSid[] = "$Id$";
3   #endif
6
4   /*
5   *  Circle sources in a displayed image.
6   *
# Line 16 | Line 13 | static char SCCSid[] = "$SunId$ LBL";
13   #include <X11/Xlib.h>
14   #include <X11/Xutil.h>
15  
19 #ifndef BSD
20 #define vfork   fork
21 #endif
22
16   #define XIM             "ximage"
17  
18   #define NSEG            30              /* number of segments per circle */
# Line 29 | Line 22 | static char SCCSid[] = "$SunId$ LBL";
22   float   col[3] = {1.,0.,0.};            /* color */
23  
24   VIEW    ourview = STDVIEW;              /* view for picture */
25 < int     xres, yres;                     /* picture resolution */
25 > RESOLU  pres;                           /* picture resolution */
26  
27   char    *progname;                      /* program name */
28  
# Line 46 | Line 39 | main(argc, argv)
39   int     argc;
40   char    *argv[];
41   {
49        extern double   atof();
42          char    *windowname = NULL;
43          FILE    *fp;
44  
# Line 91 | Line 83 | char   *pname, *wname;
83          XWindowAttributes       wa;
84          XColor  xc;
85          XGCValues       gcv;
86 +        register int    i;
87                                          /* get the viewing parameters */
88 <        if (viewfile(pname, &ourview, &xres, &yres) <= 0 ||
88 >        if (viewfile(pname, &ourview, &pres) <= 0 ||
89                          setview(&ourview) != NULL) {
90                  fprintf(stderr, "%s: cannot get view from \"%s\"\n",
91                                  progname, pname);
# Line 106 | Line 99 | char   *pname, *wname;
99                  exit(1);
100          }
101                                          /* find our window */
102 <        if (wname == NULL)
103 <                wname = pname;
104 <        gwind = xfindwind(theDisplay, rwind, wname, 2);
102 >        if (wname == NULL) {
103 >                                /* remove directory prefix from name */
104 >                for (i = strlen(pname); i-- > 0; )
105 >                        if (pname[i] == '/')
106 >                                break;
107 >                wname = pname+i+1;
108 >                i = 0;
109 >        } else
110 >                i = 1;
111 >        gwind = xfindwind(theDisplay, rwind, wname, 4);
112          if (gwind == None) {
113 <                if (wname != pname) {
113 >                if (i) {
114                          fprintf(stderr, "%s: cannot find \"%s\" window\n",
115                                          progname, wname);
116                          exit(2);
117                  }
118                                          /* start ximage */
119 <                if (vfork() == 0) {
120 <                        execlp(XIM, XIM, pname, 0);
119 >                if (fork() == 0) {
120 >                        execlp(XIM, XIM, "-c", "256", pname, 0);
121                          perror(XIM);
122                          fprintf(stderr, "%s: cannot start %s\n",
123                                          progname, XIM);
# Line 126 | Line 126 | char   *pname, *wname;
126                  }
127                  do
128                          sleep(8);
129 <                while ((gwind=xfindwind(theDisplay,rwind,pname,2)) == None);
129 >                while ((gwind=xfindwind(theDisplay,rwind,wname,4)) == None);
130          } else
131                  XMapRaised(theDisplay, gwind);
132          do {
133                  XGetWindowAttributes(theDisplay, gwind, &wa);
134                  sleep(6);
135          } while (wa.map_state != IsViewable);
136 <        if (wa.width != xres || wa.height != yres) {
136 >        if (wa.width != scanlen(&pres) || wa.height != numscans(&pres)) {
137                  fprintf(stderr,
138                  "%s: warning -- window seems to be the wrong size!\n",
139                                  progname);
140 <                xres = wa.width;
141 <                yres = wa.height;
140 >                if (pres.rt & YMAJOR) {
141 >                        pres.xr = wa.width;
142 >                        pres.yr = wa.height;
143 >                } else {
144 >                        pres.xr = wa.height;
145 >                        pres.yr = wa.width;
146 >                }
147          }
148                                          /* set graphics context */
149          gcv.font = XLoadFont(theDisplay, FONTNAME);
# Line 205 | Line 210 | double dom;
210   {
211          FVECT   start, cur;
212          XPoint  pt[NSEG+1];
213 <        double  px, py, pz;
213 >        FVECT   pp;
214 >        int     ip[2];
215          register int    i;
216  
217          fcross(cur, dir, ourview.vup);
# Line 217 | Line 223 | double dom;
223                  cur[0] += ourview.vp[0];
224                  cur[1] += ourview.vp[1];
225                  cur[2] += ourview.vp[2];
226 <                viewpixel(&px, &py, &pz, &ourview, cur);
227 <                if (pz <= 0.0)
226 >                viewloc(pp, &ourview, cur);
227 >                if (pp[2] <= 0.0)
228                          goto fail;
229 <                pt[i].x = px*xres;
230 <                pt[i].y = yres-1 - (int)(py*yres);
229 >                loc2pix(ip, &pres, pp[0], pp[1]);
230 >                pt[i].x = ip[0];
231 >                pt[i].y = ip[1];
232          }
233          XDrawLines(theDisplay, gwind, vecGC, pt, NSEG+1, CoordModeOrigin);
234          return;
# Line 236 | Line 243 | FVECT  dir;
243   double  v;
244   {
245          FVECT   pos;
246 <        double  px, py, pz;
246 >        FVECT   pp;
247 >        int     ip[2];
248          char    buf[32];
249  
250          pos[0] = ourview.vp[0] + dir[0];
251          pos[1] = ourview.vp[1] + dir[1];
252          pos[2] = ourview.vp[2] + dir[2];
253 <        viewpixel(&px, &py, &pz, &ourview, pos);
254 <        if (pz <= 0.0)
253 >        viewloc(pp, &ourview, pos);
254 >        if (pp[2] <= 0.0)
255                  return;
256 +        loc2pix(ip, &pres, pp[0], pp[1]);
257          sprintf(buf, "%.0f", v);
258          XDrawImageString(theDisplay, gwind, strGC,
259 <                        (int)(px*xres), yres-1-(int)(py*yres),
251 <                        buf, strlen(buf));
259 >                        ip[0], ip[1], buf, strlen(buf));
260   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines