Back to index

radiance  4R0+20100331
Defines | Functions | Variables
xglaresrc.c File Reference
#include "standard.h"
#include <unistd.h>
#include <signal.h>
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include "view.h"

Go to the source code of this file.

Defines

#define XIM   "ximage"
#define NSEG   30 /* number of segments per circle */
#define FONTNAME   "8x13" /* text font we'll use */
#define rwind   RootWindow(theDisplay,ourScreen)
#define ourScreen   DefaultScreen(theDisplay)

Functions

static void init (char *pname, char *wname)
static void circle_sources (FILE *fp)
static void circle (FVECT dir, double dom)
static void value (FVECT dir, double v)
int main (int argc, char *argv[])

Variables

static const char RCSid [] = "$Id: xglaresrc.c,v 2.9 2004/03/26 23:34:24 schorsch Exp $"
float col [3] = {1.,0.,0.}
VIEW ourview = STDVIEW
RESOLU pres
char * progname
Display * theDisplay = NULL
GC vecGC
GC strGC
Window gwind

Define Documentation

#define FONTNAME   "8x13" /* text font we'll use */

Definition at line 23 of file xglaresrc.c.

#define NSEG   30 /* number of segments per circle */

Definition at line 21 of file xglaresrc.c.

#define ourScreen   DefaultScreen(theDisplay)

Definition at line 35 of file xglaresrc.c.

#define rwind   RootWindow(theDisplay,ourScreen)

Definition at line 34 of file xglaresrc.c.

#define XIM   "ximage"

Definition at line 19 of file xglaresrc.c.


Function Documentation

static void circle ( FVECT  dir,
double  dom 
) [static]

Definition at line 223 of file xglaresrc.c.

{
       FVECT  start, cur;
       XPoint pt[NSEG+1];
       FVECT  pp;
       int    ip[2];
       register int  i;

       fcross(cur, dir, ourview.vup);
       if (normalize(cur) == 0.0)
              goto fail;
       spinvector(start, dir, cur, acos(1.-dom/(2.*PI)));
       for (i = 0; i <= NSEG; i++) {
              spinvector(cur, start, dir, 2.*PI*i/NSEG);
              cur[0] += ourview.vp[0];
              cur[1] += ourview.vp[1];
              cur[2] += ourview.vp[2];
              viewloc(pp, &ourview, cur);
              if (pp[2] <= 0.0)
                     goto fail;
              loc2pix(ip, &pres, pp[0], pp[1]);
              pt[i].x = ip[0];
              pt[i].y = ip[1];
       }
       XDrawLines(theDisplay, gwind, vecGC, pt, NSEG+1, CoordModeOrigin);
       return;
fail:
       fprintf(stderr, "%s: cannot draw source at (%f,%f,%f)\n",
                     progname, dir[0], dir[1], dir[2]);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void circle_sources ( FILE *  fp) [static]

Definition at line 193 of file xglaresrc.c.

{
       char   linbuf[256];
       int    reading = 0;
       FVECT  dir;
       double dom, lum;

       while (fgets(linbuf, sizeof(linbuf), fp) != NULL)
              if (reading) {
                     if (!strncmp(linbuf, "END", 3)) {
                            XFlush(theDisplay);
                            return;
                     }
                     if (sscanf(linbuf, "%lf %lf %lf %lf %lf",
                                   &dir[0], &dir[1], &dir[2],
                                   &dom, &lum) != 5)
                            break;
                     circle(dir, dom);
                     value(dir, lum);
              } else if (!strcmp(linbuf, "BEGIN glare source\n"))
                     reading++;

       fprintf(stderr, "%s: error reading glare sources\n", progname);
       exit(1);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void init ( char *  pname,
char *  wname 
) [static]
int main ( int  argc,
char *  argv[] 
)

Definition at line 47 of file xglaresrc.c.

{
       char   *windowname = NULL;
       FILE   *fp;

       progname = *argv++; argc--;
       while (argc > 0 && argv[0][0] == '-') {
              switch (argv[0][1]) {
              case 'n':
                     windowname = *++argv;
                     argc--;
                     break;
              case 'c':
                     col[0] = atof(*++argv);
                     col[1] = atof(*++argv);
                     col[2] = atof(*++argv);
                     argc -= 3;
                     break;
              }
              argv++; argc--;
       }
       if (argc < 1 || argc > 2) {
              fprintf(stderr,
              "Usage: %s [-n windowname][-c color] picture [glaresrc]\n",
                            progname);
              exit(1);
       }
       init(argv[0], windowname);
       if (argc < 2)
              fp = stdin;
       else if ((fp = fopen(argv[1], "r")) == NULL) {
              fprintf(stderr, "%s: cannot open \"%s\"\n", progname, argv[1]);
              exit(1);
       }
       circle_sources(fp);
       exit(0);
}

Here is the call graph for this function:

static void value ( FVECT  dir,
double  v 
) [static]

Definition at line 259 of file xglaresrc.c.

{
       FVECT  pos;
       FVECT  pp;
       int    ip[2];
       char   buf[32];

       pos[0] = ourview.vp[0] + dir[0];
       pos[1] = ourview.vp[1] + dir[1];
       pos[2] = ourview.vp[2] + dir[2];
       viewloc(pp, &ourview, pos);
       if (pp[2] <= 0.0)
              return;
       loc2pix(ip, &pres, pp[0], pp[1]);
       sprintf(buf, "%.0f", v);
       XDrawImageString(theDisplay, gwind, strGC,
                     ip[0], ip[1], buf, strlen(buf)); 
}

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation

float col[3] = {1.,0.,0.}

Definition at line 25 of file xglaresrc.c.

Window gwind

Definition at line 38 of file xglaresrc.c.

Definition at line 27 of file xglaresrc.c.

Definition at line 28 of file xglaresrc.c.

char* progname

Definition at line 30 of file xglaresrc.c.

const char RCSid[] = "$Id: xglaresrc.c,v 2.9 2004/03/26 23:34:24 schorsch Exp $" [static]

Definition at line 2 of file xglaresrc.c.

GC strGC

Definition at line 37 of file xglaresrc.c.

Display* theDisplay = NULL

Definition at line 32 of file xglaresrc.c.

GC vecGC

Definition at line 37 of file xglaresrc.c.