Back to index

radiance  4R0+20100331
Defines | Functions | Variables
xmeta.c File Reference
#include "rtprocess.h"
#include "string.h"
#include "meta.h"
#include "plot.h"

Go to the source code of this file.

Defines

#define overlap(p, xmn, ymn, xmx, ymx)
#define ov(mn1, mx1, mn2, mx2)   ((mn1)<(mx2)&&(mn2)<(mx1))
#define XCOM   "pexpand +OCIsv -P %s"

Functions

void init (char *name, char *geom)
void pXFlush (void)
void save (PRIMITIVE *p)
void doglobal (PRIMITIVE *g, int sf)
void doprim (PRIMITIVE *p, int sf)
void plot (FILE *infp)
void replay (int xmin, int ymin, int xmax, int ymax)
int main (int argc, char **argv)

Variables

static const char RCSid [] = "$Id: xmeta.c,v 1.5 2007/11/21 18:51:05 greg Exp $"
char * progname
static short newpage = TRUE
static PLIST recording
int maxalloc = 0

Define Documentation

#define ov (   mn1,
  mx1,
  mn2,
  mx2 
)    ((mn1)<(mx2)&&(mn2)<(mx1))

Definition at line 22 of file xmeta.c.

#define overlap (   p,
  xmn,
  ymn,
  xmx,
  ymx 
)
Value:
(ov((p)->xy[XMN],(p)->xy[XMX],xmn,xmx) \
                                 &&ov((p)->xy[YMN],(p)->xy[YMX],ymn,ymx))

Definition at line 19 of file xmeta.c.

#define XCOM   "pexpand +OCIsv -P %s"

Definition at line 24 of file xmeta.c.


Function Documentation

void doglobal ( PRIMITIVE *  g,
int  sf 
)

Definition at line 52 of file xmeta.c.

{

    switch (g->com) {

       case PEOF:
           return;

       case PDRAW:
           pXFlush();
           break;

       case PEOP:
           endpage();
           plfree(&recording);
           set(SALL, NULL);
           newpage = TRUE;
           return;

       case PSET:
           set(g->arg0, g->args);
           break;

       case PUNSET:
           unset(g->arg0);
           break;

       case PRESET:
           reset(g->arg0);
           break;

       default:
           sprintf(errmsg, "unknown command '%c' in doglobal", g->com);
           error(WARNING, errmsg);
           return;
       }
       if (sf)
           save(g);

}

Here is the call graph for this function:

Here is the caller graph for this function:

void doprim ( PRIMITIVE *  p,
int  sf 
)

Definition at line 97 of file xmeta.c.

{

    switch (p->com) {

       case PMSTR:
           printstr(p);
           break;

       case PLSEG:
           plotlseg(p);
           break;

       case PRFILL:
           fillrect(p);
           break;

       case PTFILL:
           filltri(p);
           break;

       case PPFILL:
           fillpoly(p);
           break;

       default:
           sprintf(errmsg, "unknown command '%c' in doprim", p->com);
           error(WARNING, errmsg);
           return;
    }
    if (sf) {
       save(p);
       newpage = FALSE;
    }

}

Here is the call graph for this function:

void init ( char *  name,
char *  geom 
)

Definition at line 99 of file x11plot.c.

{
    char  defgeom[32];
    XColor  cdef,dum;
    XEvent  evnt;

    curfont = curfill = curcol = -1;
    curlinetype = 0;

    if ((dpy=XOpenDisplay("")) == NULL)
       error(SYSTEM, "can't open display");
    
    /* for debugging so we don't have to flush always */
    if (debug) 
       (void) XSynchronize(dpy, True);

    dxsize = DisplayWidth(dpy,0) - 2*BORWIDTH-4;
    dysize = DisplayHeight(dpy,0) - 2*BORWIDTH-100;
    adjustsize();

    sprintf(defgeom, "=%dx%d+2+25", dxsize, dysize);
    /* XUseGeometry(dpy,0,geom,defgeom,BORWIDTH,100,100,100,100,
              &xoff,&yoff,&dxsize,&dysize); */
    gc = DefaultGC(dpy,0);                /* get default gc */
    cmap = DefaultColormap(dpy,0);        /* and colormap */

    wind = XCreateSimpleWindow(dpy,DefaultRootWindow(dpy),0,0,dxsize,dysize,
              BORWIDTH,BlackPix,WhitePix);
    if (wind == 0)
       error(SYSTEM, "can't create window");
    XStoreName(dpy, wind, name);
    XMapRaised(dpy, wind);
    XSelectInput(dpy, wind, StructureNotifyMask | ButtonPressMask | ExposureMask);
    if (DisplayPlanes(dpy,0) < 2) {       /* less than 2 color planes, use black */
           pixel[0] = pixel[1] = pixel[2] = pixel[3] = BlackPix;
    } else {
       if (XAllocNamedColor(dpy, cmap, "black", &dum, &cdef)==0)
              error(USER,"cannot allocate black!");
       pixel[0] = cdef.pixel;
       if (XAllocNamedColor(dpy, cmap, "red", &dum, &cdef)==0)
              {
              error(WARNING,"cannot allocate red");
              cdef.pixel = BlackPix;
              }
       pixel[1] = cdef.pixel;
       if (XAllocNamedColor(dpy, cmap, "green", &dum, &cdef)==0)
              {
              error(WARNING,"cannot allocate green");
              cdef.pixel = BlackPix;
              }
       pixel[2] = cdef.pixel;
       if (XAllocNamedColor(dpy, cmap, "blue", &dum, &cdef)==0)
              {
              error(WARNING,"cannot allocate blue");
              cdef.pixel = BlackPix;
              }
       pixel[3] = cdef.pixel;
    }

    while (1)
       {
       XNextEvent(dpy, &evnt);
       if (evnt.type == ConfigureNotify) /* wait for first ConfigureNotify */
              break;
       }
    dxsize = evnt.xconfigure.width;
    dysize = evnt.xconfigure.height;
    adjustsize();
    while (1)
       {
       XNextEvent(dpy, &evnt);
       if (evnt.type == Expose)    /* wait for first Expose */
              break;
       }
}

Here is the call graph for this function:

int main ( int  argc,
char **  argv 
)

Definition at line 175 of file xmeta.c.

{
 FILE  *fp;
 char  *geometry = NULL;
 short  condonly, conditioned;
 char  comargs[500], command[600];

 progname = *argv++;
 argc--;

 condonly = FALSE;
 conditioned = FALSE;

 for ( ; argc; argv++, argc--)
    if (!strcmp(*argv, "-c"))
       condonly = TRUE;
    else if (!strcmp(*argv, "-r"))
       conditioned = TRUE;
    else if (**argv == '=')
       geometry = *argv;
    else
       break;

 if (conditioned) {
    init(progname, geometry);
    if (argc) 
       while (argc)  {
         fp = efopen(*argv, "r");
         plot(fp);
         fclose(fp);
         argv++;
         argc--;
         }
    else
       plot(stdin);
 } else  {
    comargs[0] = '\0';
    while (argc)  {
       strcat(comargs, " ");
       strcat(comargs, *argv);
       argv++;
       argc--;
       }
    sprintf(command, XCOM, comargs);
    if (condonly)
       return(system(command));
    else  {
       init(progname, geometry);
       if ((fp = popen(command, "r")) == NULL)
          error(SYSTEM, "cannot execute input filter");
       plot(fp);
       pclose(fp);
       }
    }

 if (!newpage)
     endpage();

 return(0);
 }

Here is the call graph for this function:

void plot ( FILE *  infp)

Definition at line 138 of file xmeta.c.

{
    PRIMITIVE  nextp;

    set(SALL, NULL);
    do {
       readp(&nextp, infp);
       while (isprim(nextp.com)) {
           doprim(&nextp, 1);
           readp(&nextp, infp);
       }
       doglobal(&nextp, 1);
    } while (nextp.com != PEOF);

}

Here is the call graph for this function:

void pXFlush ( void  )

Definition at line 304 of file x11plot.c.

{
       XFlush(dpy);
}

Here is the caller graph for this function:

void replay ( int  xmin,
int  ymin,
int  xmax,
int  ymax 
)

Definition at line 157 of file xmeta.c.

{
    register PRIMITIVE  *p;

    unset(SALL);
    set(SALL, NULL);
    for (p = recording.ptop; p != NULL; p = p->pnext)
       if (isprim(p->com)) {
           if (overlap(p, xmin, ymin, xmax, ymax))
              doprim(p, 0);
       } else
           doglobal(p, 0);

}

Here is the call graph for this function:

Here is the caller graph for this function:

void save ( PRIMITIVE *  p)

Definition at line 39 of file xmeta.c.

{
    register PRIMITIVE  *pnew;

    if ((pnew = palloc()) == NULL)
           error(SYSTEM, "out of memory in save");
    mcopy((char *)pnew, (char *)p, sizeof(PRIMITIVE));
    add(pnew, &recording);
}

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation

int maxalloc = 0

Definition at line 33 of file xmeta.c.

short newpage = TRUE [static]

Definition at line 29 of file xmeta.c.

char* progname

Definition at line 27 of file xmeta.c.

const char RCSid[] = "$Id: xmeta.c,v 1.5 2007/11/21 18:51:05 greg Exp $" [static]

Definition at line 2 of file xmeta.c.

PLIST recording [static]

Definition at line 31 of file xmeta.c.