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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines