Sindbad~EG File Manager

Current Path : /usr/home/beeson/MathXpert/
Upload File :
Current File : /usr/home/beeson/MathXpert/graphstr.h

/* M. Beeson, for Mathpert */

/* Data private to each graph document consists primarily of an array
of 'graph' structures, one for each function being graphed. Also, if
parameters are involved, there will be an array of
parameters,  their current values, and a history of the past values
that were used to draw graphs that are still visible (and so must be
redrawn e.g. to print the graph)  */

#include "maxparam.h"
/*___________________________________________________________*/
/* A graph paper can have three kinds of lines, major, minor,
and vellum.  All are optional.  Vellum lines are always just
1 pixel thick and closest together.  If there are minor lines
they are half as far apart as major lines.  Then the number of
vellum lines per major line  should be even.  Each kind of line
can have its own color, and major and minor lines can have their
own thickness.
*/
/*___________________________________________________________*/
typedef struct gr
{ int index;       // position in the array maintained in grpaper.c
                   // zero is the dummy entry meaning no graph paper
  unsigned  background;
  unsigned  color1;  // color for the major lines
  unsigned  color2;  // color for the minor lines
  unsigned  color3;  // color for the vellum lines, if any
                     // if color3 == 0 it means no vellum lines
  int ncolors;     // 1,2, or 3 unless this is noPaper, which has 0 here
                   // 1 means there are no minor or vellum lines, only major lines
  int nlines;      // number of vellum lines per major line, if
                   // there are vellum lines; or number of minor lines
                   // per major line.  If there are both minor and
                   // vellum lines this should be even, as then
                   // the minor lines are halfway between major lines.
  int spacingPoints; // spacing between major lines in printer's points (1/72 inch)
                   // must be an integer multiple of nlines
  double thickness1;  // thickness of major lines and axes, in pixels.  Pixels are the same as printer's points.  
  double thickness2;  // thickness of minor lines, in pixels
  /* The following fields give the default color scheme to be used
  with this graph paper if the user has specified automatic selection */
  unsigned  titlebackgroundcolor;
  unsigned  titlecolor;
  unsigned  axescolor;
  unsigned  axeslabelcolor;
} GraphPaper;
 
/*___________________________________________________________*/
/* structure type for graph definition */
/* all kinds of graphs use this same structure type */
/* represents a single viewport and axes with just one function */
/* data called for in this structure will be filled in before
     drawing a graph */
/*  pxmin etc. fields are pixel coordinates of this graph relative to
    the rectangle that contains all the graphs but not the toolbar.
    dxmin etc. fields are normalized device coordinates relative to
    that same rectangle.   These have (0,0) at lower left and (1,1) at upper right.
*/


typedef struct {
    int graphtype;       /*  ORDINARY, PARAMETRIC, POLAR, POLAR_CIRCULAR,
                             ODE, ODESYSTEM, ODE2, HDE, POLYROOT  */
    int numberofpoints;  /* how many points to plot               */
    double linewidth;    /* thickness in CSS pixels, 1,2, or 3    */
    unsigned graphcolor;
    unsigned background;    /* background color                   */
    unsigned fillcolor;     /* used for inequalities              */
    unsigned border;   /* border color, if same as background then no border */
    unsigned axescolor;     /* color for the tick labels too      */
    unsigned axeslabelcolor; /* color for either numerical or symbolic labels */
    unsigned titlecolor;
    unsigned titlebackgroundcolor;
    unsigned ticks:2;         /* nonzero if we want ticks drawn and labeled         */
                   /* value of 2 indicates ticks should be multiples of pi   */
    unsigned labels: 2;        /* numerical or symbolic labels or no labels on axes? */
                       /* 0 = no labels,
                          1 = numbers,
                          2 = symbolic labels (just names of variables)
                       */
    unsigned savezooms:1;   /*  save zoomed coordinates for next time?       */
    unsigned saveparams:1;  /*  save parameter values for next time?         */
    unsigned showtitles:1;  /*  should the title be visible?                 */
    unsigned tool: 3;        /* 0 = no tool, 1 = PointSlope, 2 = Hand,
                                3 = centered rectangle, 4 = uncentered rectangle */
    int whichgraph;         /*  index i such that this graph is graphs[i]    */
    term function;          /* the function to be graphed                    */
    term fprime;            /* its derivative, in case of ordinary graphs    */
    term gprime;            /* used for graphing inequalities                */
    term xfunction;         /* coordinate functions for a parametric graph   */
    term yfunction;
    term independent_variable;   /* x for ordinary graphs                    */
                            /* t for parametric or polar graphs              */
                            /*  x for relation or contour plots              */
    term dependent_variable;  /* y for ordinary graphs, relation, or
                                contour plots                                */
    char *rvariable;        /* used for polar graphs only                    */
    char *xvariable;        /* variables with which to label x and y axes    */
    char *yvariable;
    term parameter_interval;  /* e.g. 0 <= x <= 2 pi, not using doubles      */
    double tmin,tmax;       /* extreme parameter values for parametric graph */
                            /* tmin is used for spacing in contour plots     */
    double tselected;       /* to locate a movable dot on a parametric graph */
    double xmin,xmax,ymin,ymax;  /* world coordinates of visible portion     */
    term *slist;            /* array of expressions for singularities        */
                            /* or, if mainchoice == ODE, ODE2, HDE, or
                               ODESYSTEM, this is used for the array of
                               right-hand sides f in  y' = f(x,y)            */
    int dimslist;           /* dimension of that array                       */
    term *jumplist;         /* array of expressions for jump discontinuities */
    int dimjumplist;        /* dimension of that array                       */
    term *openlist;         /* array of expressions for open circles         */
    int dimopen;            /* dimension of that array                       */
    term *closedlist;       /* array of expressions for closed circles       */
    int dimclosed;          /* dimension of that array;                      */
    term *srestrictions;    /* array of inequalities restricting
                               parameter values in slist                     */
    int dimsrestrictions;   /* dimension of that array                       */
    term *jumprestrictions; /* array of inequalities restricting parameter
                               values in jumplist                            */
    int dimjumprestrictions;/* dimension of that array                       */
    term *elist;            /* if mainchoice == ODE, ODE2, ODESYSTEM, HDE,
                               this is used for the array of
                               dependent variable names                      */
    int dimelist;           /* dimension of that array                       */
    double *singularities;  /* pointer to array of singularities (the x-values) */
    int nsingularities;     /* dimension of that array                       */
    double **initial_values; /* array of pointers to initial values of ODE, ODE2, ODESYSTEM, HDE  */
                            /* dimelist is the number of initial values      */
    double *jumps;          /* numerical jump discontinuities                */
    int njumps;             /* dimension of jumps array                      */
    double dxmin,dymin;     /* normalized device coordinates of viewport     */
    double dxmax,dymax;     /*  (0,0) is lower left                          */
    int pxmin,pxmax;        /* pixel coordinates of viewport relative to
                               the window containing this graph structure.
                               If ngraphs > 1 this is not the whole window.  */
    int pymin,pymax;        /* (0,0) is upper left                           */
    term title;             /* bblocked term if any already written for title
                               on these axes; used when g.whichgraph > 0     */
    double txmin,tymin,txmax,tymax;  /* norm. dev. coords. of title viewport */
    term xminsym, xmaxsym, yminsym, ymaxsym;  /* symbolic values for
                                        use on axis labels before zooming    */

    double selectedx, selectedy; /* crosshair cursor location in this graph  */
    double pencil_left, pencil_top, pencil_right, pencil_bottom;
                            /* rectangle selected by pencil, if any          */
    int whichparams[MAXPARAMS];  /* whichparams[i] is nonzero if
                                    parameters[i] is used in this graph      */
    parameter *parameters;  /* pointer to the relevant array of parameters   */
    int activeparameter;     /* index in parameters array of the active parameter */
                             /* set before drawing takes place from pDocData->activeparameter */
    unsigned newaxes:1;      /* This is the first graph on these axes        */
                             /* second graph on same axes should ALWAYS
                                have this field zero                          */
    unsigned erase:1;        /* zero means to leave old graphs (with old
                                parameter values) on the screen, if there were
                                no zooms or newly selected center             */
    unsigned crosshairsflag:1; /* nonzero means the crosshairs is visible  */
    unsigned rectangle_flag:1; /* nonzero means selected rectangle is visible */
    int dfield:2;  /* for an ODE, nonzero if the direction field is visible */
    unsigned dfield_applicable:1; /* 1 if a direction field makes sense   */
                             /* i.e. for y'=f(x,y), or for system
                                y'=f(x,y), x'=g(x,y), but not for higher-order
                                equations, systems of more than 2 variables,
                                or y' = f(x,y,t), x' = g(x,y,t)               */
    unsigned update:1;       /* for 3d graph, means must recompute surface  */
    unsigned nparameters:4;  /* number of parameters used in this graph     */
                             /* = number of nonzero entries in whichparams  */
    unsigned riemannflag:2;  /* 0 = left, 1 = right, 2 = midpoint           */
    double *root_xcoords;       /* arrays of pixel coordinates of roots     */
    double *root_ycoords;
    int nroots;              /* dimension of the previous two arrays        */
    term nintervals;         /* used for RIEMANNSUMS and SIMPSONSRULE       */
    double left;             /* interval for RIEMANNSUMS and SIMPSONSRULE   */
    double right;
    double area;             /* value of the Riemann sum or other appx      */
    int adjustToPaper;       /* setting to zero disables AdjustGraphRanges  */
    int circular;           /* this graph should have aspect ratio 1        */
    int tempsing;           /* if nonzero, singularities and jumps need
                               recalculation when parameters change         */
    GraphPaper grpaper;     /* has 0 for index and ncolors if graph paper is
                               not used on this graph    */
         /* rest of the structure is used for 3d plots only   */
         /* Nevertheless every graph gets these fields. It's only
            a couple of hundred bytes. */
    char *zvariable;
    term independent_variable2;
    term zfunction;
    double zmin, zmax;
    double umin, umax, vmin, vmax;
    int rendermode;           /* wire-frame, hidden-line,
                                 no shading, flat shading,
                                 gouraud shading, or phong shading,
                                 given by #defined values in RenderLib */
    double camera[3];         /* camera location */
    double camera_rotation;   /* in degrees */
    double focus[3];          /* point at which camera is looking */
    double lamp1[3];          /* lamp location */
    double lamp2[3];          /* optional second lamp */
    int lamp1flag:8;          /* intensity of first lamp in percent */
    int lamp2flag:8;          /* intensity of second lamp in percent */
    unsigned lamp1color;      /* color of first lamp */
    unsigned lamp2color;      /* color of second lamp */
    void *points;             /* three arrays used in 3d graphs */
    void *index;
    void *normals;
    int npoints;              /* dimension of the points and normals arrays */
    int nindex;               /* dimension of the index array */
} graph;

#include "mainchoi.h"    /* values of mainchoice */

/* linewidths for drawing graphs:  */
#define  THIN 1.0  /* will be rounded and read as pixels for screen devices OR printers */
#define THICK 3.0

/*______________________________________________________________*/
/* values for the argument to function 'position'  */

#define FULLSQUARE 0
#define FULLSCREEN 1
/* if you add more one-graph possibilities put them here */
#define UPPERLEFT 2

#define STACKEDRECTANGLES 3
/* any future two-or-more-graph possibilities go here */
#define TWOSQUARES 4

/*_____________________________________________________________________*/

#define DEC_PARAM(index)  *(parameters[index].addr) -= parameters[index].increment
#define INC_PARAM(index)  *(parameters[index].addr) += parameters[index].increment
/* see set_param in graph.c */


Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists