next up previous contents
Next: Examples from Edge Tool Up: Programmer Graphics Support Previous: Histogram Manipulation   Contents

Graph Plotting

The Tina system supports graphical display of data under a reduced version of the $Tv Tool$ structure. Display of data on this device is supported from the function $plot(int case\_flag, ...)$ which takes a variable argument list of flags followed by associated data. These flags comprise:
      Control Flag   Prameters           Description

      PL_INIT         No params.       : initialise graphics
      PL_FREE         No params.       : free graphics structures
      PL_TV           Tv *tv           : set up display Tv
      PL_COLOR        int color        : plot colour
      PL_AXIS_COLOR   int color        : axis colour
      PL_STYLE        int style        : plot style
      PL_TITLE        char *title      : title
      PL_LEGEND       char *legend     : legend
      PL_AXES         Bool set         : set both axes
      PL_TICS         Bool set         : display with axis ticks
      PL_TEXT         Bool set         : overlay text string
      PL_X_AXIS       Bool set         : set x axis
      PL_X_TICS       Bool set         : display with x axis ticks
      PL_X_TEXT       Bool set         : x axis text
      PL_X_RANGE      double xmin      
                      double xmax
                      double xinc      : x range
      PL_Y_AXIS       Bool set         : set y axis
      PL_Y_TICS       Bool set         : display with y axis ticks
      PL_Y_TEXT       Bool set         : y axis text
      PL_Y_RANGE      double ymin
                      double ymax
                      double yinc      : y range
      PL_XFORMAT      char *fm         : set x axis display format 
      PL_YFORMAT      char *fm         : set y axis display format
      PL_GRAPH_DATA   int n
                      float *z         : data as a graph
      PL_SCATTER_DATA int n
                      float *x
                      float *y         : data as a scatter plot
      PL_GRAPH_FUNC   int n
                      double a
                      double b
                      double (*f) ()   : data from a function
      PL_HIST_RANGE   double zmin
                      double zmax
                      double zinc      : set histogram range
      PL_HIST_DATA    int n          
                      float *z         : data as a histogram
      PL_CUMHIST_DATA int n
                      float *z         : data as a cumulative histogram
      PL_CTR_RANGE    double cmin
                      double cmax
                      double cin       : set contour plot range
      PL_CTR_DATA     int nx
                      float *x
                      int ny
                      float *y
                      float **z        : data as a contour surface
      PL_CTR_FUNC     int nx
                      double ax
                      double bx
                      int ny
                      double ay
                      double by
                      double (*f) ()   : data as a contour function
      PL_PLOT         No params.       : execute plotting

This functionality can easily be controlled using the data stored in the histogramming structures. Typical use of this display software would look something like the following example, taken from the $Calib Tool$.

static Tv *graph_tv = NULL;
static double accuracy = 1.0;
.
.
.
static void graph_tool_proc(void)
{
    extern void *display_tool();

    graph_tool = (void *) display_tool(100, 200, 400, 256);
    graph_tv = tv_create("graph");
    tv_install(graph_tv, graph_tool);
}
.
.
.
static void epierr_proc(void)
{
    double *epi_err;
    float   lx[512];
    int     i, n_data = 1024;
    Vec2   *leftpix_get();
    Vec2   *rightpix_get();

    if (leftcam == NULL || rightcam == NULL)
        return;
    if (graph_tool == NULL)
    {
        error("no graph tv_screen", warning);
        return;
    }
    tv_erase(graph_tv);
    epi_err = (double *) ralloc(sizeof(double) * (unsigned int) n_data);
    (void) triv_camerror(&n_data, epi_err, leftcam, rightcam,
                         world3d, leftpix_get, rightpix_get, accuracy);
    if (n_data == 1024)
    {
        format("warning only 512 data points displayed\n");
    }
    for (i = 1; i < n_data; i += 2)
    {
        lx[i / 2] = (float) epi_err[i];
        if (lx[i / 2] >= 3.0 * accuracy)
            lx[i / 2] = 3.0 * accuracy;
        if (lx[i / 2] < -3.0 * accuracy)
            lx[i / 2] = -3.0 * accuracy;
    }
    n_data /= 2;
    plot(PL_INIT,

         PL_TV, graph_tv,
         PL_AXIS_COLOR, black,
         PL_TITLE, "epi-polar error",
         PL_HIST_RANGE, -3.0*accuracy, 3.0*accuracy, 3.0*accuracy / 30.0,

         PL_COLOR, red,
         PL_HIST_DATA, n_data, lx,

         PL_PLOT,
         NULL);

    rfree((void *) epi_err);
}



root 2017-09-20