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.5 by greg, Thu Apr 29 12:58:20 1993 UTC

# Line 12 | Line 12 | static char SCCSid[] = "$SunId$ LBL";
12  
13   #include "standard.h"
14   #include "view.h"
15 + #include "resolu.h"
16 + #include "vfork.h"
17   #include <signal.h>
18   #include <X11/Xlib.h>
19   #include <X11/Xutil.h>
20  
19 #ifndef BSD
20 #define vfork   fork
21 #endif
22
21   #define XIM             "ximage"
22  
23   #define NSEG            30              /* number of segments per circle */
# Line 29 | Line 27 | static char SCCSid[] = "$SunId$ LBL";
27   float   col[3] = {1.,0.,0.};            /* color */
28  
29   VIEW    ourview = STDVIEW;              /* view for picture */
30 < int     xres, yres;                     /* picture resolution */
30 > RESOLU  pres;                           /* picture resolution */
31  
32   char    *progname;                      /* program name */
33  
# Line 46 | Line 44 | main(argc, argv)
44   int     argc;
45   char    *argv[];
46   {
49        extern double   atof();
47          char    *windowname = NULL;
48          FILE    *fp;
49  
# Line 91 | Line 88 | char   *pname, *wname;
88          XWindowAttributes       wa;
89          XColor  xc;
90          XGCValues       gcv;
91 +        register int    i;
92                                          /* get the viewing parameters */
93 <        if (viewfile(pname, &ourview, &xres, &yres) <= 0 ||
93 >        if (viewfile(pname, &ourview, &pres) <= 0 ||
94                          setview(&ourview) != NULL) {
95                  fprintf(stderr, "%s: cannot get view from \"%s\"\n",
96                                  progname, pname);
# Line 106 | Line 104 | char   *pname, *wname;
104                  exit(1);
105          }
106                                          /* find our window */
107 <        if (wname == NULL)
108 <                wname = pname;
109 <        gwind = xfindwind(theDisplay, rwind, wname, 2);
107 >        if (wname == NULL) {
108 >                                /* remove directory prefix from name */
109 >                for (i = strlen(pname); i-- > 0; )
110 >                        if (pname[i] == '/')
111 >                                break;
112 >                wname = pname+i+1;
113 >                i = 0;
114 >        } else
115 >                i = 1;
116 >        gwind = xfindwind(theDisplay, rwind, wname, 4);
117          if (gwind == None) {
118 <                if (wname != pname) {
118 >                if (i) {
119                          fprintf(stderr, "%s: cannot find \"%s\" window\n",
120                                          progname, wname);
121                          exit(2);
122                  }
123                                          /* start ximage */
124                  if (vfork() == 0) {
125 <                        execlp(XIM, XIM, pname, 0);
125 >                        execlp(XIM, XIM, "-c", "256", pname, 0);
126                          perror(XIM);
127                          fprintf(stderr, "%s: cannot start %s\n",
128                                          progname, XIM);
# Line 126 | Line 131 | char   *pname, *wname;
131                  }
132                  do
133                          sleep(8);
134 <                while ((gwind=xfindwind(theDisplay,rwind,pname,2)) == None);
134 >                while ((gwind=xfindwind(theDisplay,rwind,wname,4)) == None);
135          } else
136                  XMapRaised(theDisplay, gwind);
137          do {
138                  XGetWindowAttributes(theDisplay, gwind, &wa);
139                  sleep(6);
140          } while (wa.map_state != IsViewable);
141 <        if (wa.width != xres || wa.height != yres) {
141 >        if (wa.width != scanlen(&pres) || wa.height != numscans(&pres)) {
142                  fprintf(stderr,
143                  "%s: warning -- window seems to be the wrong size!\n",
144                                  progname);
145 <                xres = wa.width;
146 <                yres = wa.height;
145 >                if (pres.or & YMAJOR) {
146 >                        pres.xr = wa.width;
147 >                        pres.yr = wa.height;
148 >                } else {
149 >                        pres.xr = wa.height;
150 >                        pres.yr = wa.width;
151 >                }
152          }
153                                          /* set graphics context */
154          gcv.font = XLoadFont(theDisplay, FONTNAME);
# Line 205 | Line 215 | double dom;
215   {
216          FVECT   start, cur;
217          XPoint  pt[NSEG+1];
218 <        double  px, py, pz;
218 >        FVECT   pp;
219 >        int     ip[2];
220          register int    i;
221  
222          fcross(cur, dir, ourview.vup);
# Line 217 | Line 228 | double dom;
228                  cur[0] += ourview.vp[0];
229                  cur[1] += ourview.vp[1];
230                  cur[2] += ourview.vp[2];
231 <                viewpixel(&px, &py, &pz, &ourview, cur);
232 <                if (pz <= 0.0)
231 >                viewloc(pp, &ourview, cur);
232 >                if (pp[2] <= 0.0)
233                          goto fail;
234 <                pt[i].x = px*xres;
235 <                pt[i].y = yres-1 - (int)(py*yres);
234 >                loc2pix(ip, &pres, pp[0], pp[1]);
235 >                pt[i].x = ip[0];
236 >                pt[i].y = ip[1];
237          }
238          XDrawLines(theDisplay, gwind, vecGC, pt, NSEG+1, CoordModeOrigin);
239          return;
# Line 236 | Line 248 | FVECT  dir;
248   double  v;
249   {
250          FVECT   pos;
251 <        double  px, py, pz;
251 >        FVECT   pp;
252 >        int     ip[2];
253          char    buf[32];
254  
255          pos[0] = ourview.vp[0] + dir[0];
256          pos[1] = ourview.vp[1] + dir[1];
257          pos[2] = ourview.vp[2] + dir[2];
258 <        viewpixel(&px, &py, &pz, &ourview, pos);
259 <        if (pz <= 0.0)
258 >        viewloc(pp, &ourview, pos);
259 >        if (pp[2] <= 0.0)
260                  return;
261 +        loc2pix(ip, &pres, pp[0], pp[1]);
262          sprintf(buf, "%.0f", v);
263          XDrawImageString(theDisplay, gwind, strGC,
264 <                        (int)(px*xres), yres-1-(int)(py*yres),
251 <                        buf, strlen(buf));
264 >                        ip[0], ip[1], buf, strlen(buf));
265   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines