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.1 by greg, Tue Mar 19 14:12:11 1991 UTC vs.
Revision 1.7 by greg, Fri May 3 12:50:45 1991 UTC

# Line 12 | Line 12 | static char SCCSid[] = "$SunId$ LBL";
12  
13   #include "standard.h"
14   #include "view.h"
15 + #include <signal.h>
16   #include <X11/Xlib.h>
16 #include <X11/cursorfont.h>
17   #include <X11/Xutil.h>
18  
19 + #ifndef BSD
20 + #define vfork   fork
21 + #endif
22 +
23 + #define XIM             "ximage"
24 +
25   #define NSEG            30              /* number of segments per circle */
26  
27   VIEW    ourview = STDVIEW;              /* view for picture */
# Line 37 | Line 43 | main(argc, argv)
43   int     argc;
44   char    *argv[];
45   {
46 +        char    *windowname;
47          FILE    *fp;
48  
49          progname = argv[0];
50 +        if (argc > 2 && !strcmp(argv[1], "-n")) {
51 +                windowname = argv[2];
52 +                argv += 2;
53 +                argc -= 2;
54 +        } else
55 +                windowname = argv[1];
56          if (argc < 2 || argc > 3) {
57 <                fprintf(stderr, "Usage: %s picture [glaresrc]\n",
57 >                fprintf(stderr,
58 >                        "Usage: %s [-n windowname] picture [glaresrc]\n",
59                                  progname);
60                  exit(1);
61          }
62 <        init(argv[1]);
62 >        init(argv[1], windowname);
63          if (argc < 3)
64                  fp = stdin;
65          else if ((fp = fopen(argv[2], "r")) == NULL) {
# Line 58 | Line 72 | char   *argv[];
72   }
73  
74  
75 < init(name)                      /* set up vector drawing from pick */
76 < char    *name;
75 > init(pname, wname)              /* get view and find window */
76 > char    *pname, *wname;
77   {
78 +        extern Window   xfindwind();
79          XWindowAttributes       wa;
65        XEvent  xev;
80          XColor  xc;
81          XGCValues       gcv;
82                                          /* get the viewing parameters */
83 <        if (viewfile(name, &ourview, &xres, &yres) <= 0 ||
83 >        if (viewfile(pname, &ourview, &xres, &yres) <= 0 ||
84                          setview(&ourview) != NULL) {
85                  fprintf(stderr, "%s: cannot get view from \"%s\"\n",
86 <                                progname, name);
86 >                                progname, pname);
87                  exit(1);
88          }
89                                          /* open the display */
# Line 79 | Line 93 | char   *name;
93                                  progname);
94                  exit(1);
95          }
82        pickcursor = XCreateFontCursor(theDisplay, XC_target);
96                                          /* find our window */
97 <        while (XGrabPointer(theDisplay, rwind, True, ButtonPressMask,
98 <                        GrabModeAsync, GrabModeAsync, None, pickcursor,
99 <                        CurrentTime) != GrabSuccess)
100 <                sleep(2);
101 <        printf("%s: pick point in \"%s\" display window\n", progname, name);
102 <        XNextEvent(theDisplay, &xev);
103 <        XUngrabPointer(theDisplay, CurrentTime);
104 <        if (((XButtonEvent *)&xev)->subwindow == None) {
105 <                fprintf(stderr, "%s: no window selected\n", progname);
106 <                exit(1);
97 >        gwind = xfindwind(theDisplay, rwind, wname, 2);
98 >        if (gwind == None) {
99 >                if (wname != pname) {
100 >                        fprintf(stderr, "%s: cannot find \"%s\" window\n",
101 >                                        progname, wname);
102 >                        exit(2);
103 >                }
104 >                                        /* start ximage */
105 >                if (vfork() == 0) {
106 >                        execlp(XIM, XIM, pname, 0);
107 >                        perror(XIM);
108 >                        fprintf(stderr, "%s: cannot start %s\n",
109 >                                        progname, XIM);
110 >                        kill(getppid(), SIGPIPE);
111 >                        _exit(1);
112 >                }
113 >                do
114 >                        sleep(8);
115 >                while ((gwind=xfindwind(theDisplay,rwind,pname,2)) == None);
116 >        } else {
117 >                XMapRaised(theDisplay, gwind);
118 >                XFlush(theDisplay);
119 >                sleep(4);
120          }
95        gwind = ((XButtonEvent *)&xev)->subwindow;
96        XRaiseWindow(theDisplay, gwind);
121          XGetWindowAttributes(theDisplay, gwind, &wa);
98        sleep(4);
122          if (wa.width != xres || wa.height != yres) {
123                  fprintf(stderr,
124                  "%s: warning -- window seems to be the wrong size!\n",
# Line 165 | Line 188 | double dom;
188                  if (pz <= 0.0)
189                          goto fail;
190                  pt[i].x = px*xres;
191 <                pt[i].y = py*yres;
191 >                pt[i].y = yres-1 - (int)(py*yres);
192          }
193          XDrawLines(theDisplay, gwind, vecGC, pt, NSEG+1, CoordModeOrigin);
194          return;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines