| 8 |
|
*/ |
| 9 |
|
|
| 10 |
|
#include "standard.h" |
| 11 |
< |
#include "view.h" |
| 11 |
> |
#include "paths.h" |
| 12 |
> |
|
| 13 |
|
#include <signal.h> |
| 14 |
|
#include <X11/Xlib.h> |
| 15 |
|
#include <X11/Xutil.h> |
| 16 |
|
|
| 17 |
+ |
#include "view.h" |
| 18 |
+ |
|
| 19 |
|
#define XIM "ximage" |
| 20 |
|
|
| 21 |
|
#define NSEG 30 /* number of segments per circle */ |
| 27 |
|
VIEW ourview = STDVIEW; /* view for picture */ |
| 28 |
|
RESOLU pres; /* picture resolution */ |
| 29 |
|
|
| 27 |
– |
char *progname; /* program name */ |
| 28 |
– |
|
| 30 |
|
Display *theDisplay = NULL; /* connection to server */ |
| 31 |
|
|
| 32 |
|
#define rwind RootWindow(theDisplay,ourScreen) |
| 35 |
|
GC vecGC, strGC; |
| 36 |
|
Window gwind; |
| 37 |
|
|
| 38 |
+ |
static void init(char *pname, char *wname); |
| 39 |
+ |
static void circle_sources(FILE *fp); |
| 40 |
+ |
static void circle(FVECT dir, double dom); |
| 41 |
+ |
static void value(FVECT dir, double v); |
| 42 |
|
|
| 43 |
< |
main(argc, argv) |
| 44 |
< |
int argc; |
| 45 |
< |
char *argv[]; |
| 43 |
> |
|
| 44 |
> |
int |
| 45 |
> |
main( |
| 46 |
> |
int argc, |
| 47 |
> |
char *argv[] |
| 48 |
> |
) |
| 49 |
|
{ |
| 50 |
|
char *windowname = NULL; |
| 51 |
|
FILE *fp; |
| 52 |
|
|
| 53 |
< |
progname = *argv++; argc--; |
| 53 |
> |
fixargv0(*argv++); argc--; |
| 54 |
|
while (argc > 0 && argv[0][0] == '-') { |
| 55 |
|
switch (argv[0][1]) { |
| 56 |
|
case 'n': |
| 84 |
|
} |
| 85 |
|
|
| 86 |
|
|
| 87 |
< |
init(pname, wname) /* get view and find window */ |
| 88 |
< |
char *pname, *wname; |
| 87 |
> |
static void |
| 88 |
> |
init( /* get view and find window */ |
| 89 |
> |
char *pname, |
| 90 |
> |
char *wname |
| 91 |
> |
) |
| 92 |
|
{ |
| 93 |
|
extern Window xfindwind(); |
| 94 |
|
XWindowAttributes wa; |
| 187 |
|
} |
| 188 |
|
|
| 189 |
|
|
| 190 |
< |
circle_sources(fp) /* circle sources listed in fp */ |
| 191 |
< |
FILE *fp; |
| 190 |
> |
static void |
| 191 |
> |
circle_sources( /* circle sources listed in fp */ |
| 192 |
> |
FILE *fp |
| 193 |
> |
) |
| 194 |
|
{ |
| 195 |
|
char linbuf[256]; |
| 196 |
|
int reading = 0; |
| 203 |
|
XFlush(theDisplay); |
| 204 |
|
return; |
| 205 |
|
} |
| 206 |
< |
if (sscanf(linbuf, "%lf %lf %lf %lf %lf", |
| 207 |
< |
&dir[0], &dir[1], &dir[2], |
| 208 |
< |
&dom, &lum) != 5) |
| 206 |
> |
if (sscanf(linbuf, FVFORMAT, |
| 207 |
> |
&dir[0], &dir[1], &dir[2]) != 3 || |
| 208 |
> |
sscanf(sskip2(linbuf, 3), "%lf %lf", |
| 209 |
> |
&dom, &lum) != 2) |
| 210 |
|
break; |
| 211 |
|
circle(dir, dom); |
| 212 |
|
value(dir, lum); |
| 218 |
|
} |
| 219 |
|
|
| 220 |
|
|
| 221 |
< |
circle(dir, dom) /* indicate a solid angle on image */ |
| 222 |
< |
FVECT dir; |
| 223 |
< |
double dom; |
| 221 |
> |
static void |
| 222 |
> |
circle( /* indicate a solid angle on image */ |
| 223 |
> |
FVECT dir, |
| 224 |
> |
double dom |
| 225 |
> |
) |
| 226 |
|
{ |
| 227 |
|
FVECT start, cur; |
| 228 |
|
XPoint pt[NSEG+1]; |
| 239 |
|
cur[0] += ourview.vp[0]; |
| 240 |
|
cur[1] += ourview.vp[1]; |
| 241 |
|
cur[2] += ourview.vp[2]; |
| 242 |
< |
viewloc(pp, &ourview, cur); |
| 227 |
< |
if (pp[2] <= 0.0) |
| 242 |
> |
if (viewloc(pp, &ourview, cur) != VL_GOOD) |
| 243 |
|
goto fail; |
| 244 |
|
loc2pix(ip, &pres, pp[0], pp[1]); |
| 245 |
|
pt[i].x = ip[0]; |
| 253 |
|
} |
| 254 |
|
|
| 255 |
|
|
| 256 |
< |
value(dir, v) /* print value on image */ |
| 257 |
< |
FVECT dir; |
| 258 |
< |
double v; |
| 256 |
> |
static void |
| 257 |
> |
value( /* print value on image */ |
| 258 |
> |
FVECT dir, |
| 259 |
> |
double v |
| 260 |
> |
) |
| 261 |
|
{ |
| 262 |
|
FVECT pos; |
| 263 |
|
FVECT pp; |
| 267 |
|
pos[0] = ourview.vp[0] + dir[0]; |
| 268 |
|
pos[1] = ourview.vp[1] + dir[1]; |
| 269 |
|
pos[2] = ourview.vp[2] + dir[2]; |
| 270 |
< |
viewloc(pp, &ourview, pos); |
| 254 |
< |
if (pp[2] <= 0.0) |
| 270 |
> |
if (viewloc(pp, &ourview, pos) != VL_GOOD) |
| 271 |
|
return; |
| 272 |
|
loc2pix(ip, &pres, pp[0], pp[1]); |
| 273 |
|
sprintf(buf, "%.0f", v); |