Sindbad~EG File Manager
/* 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"
/*___________________________________________________________*/
typedef struct gr
{ int index; // position in the array maintained in grpaper.c
// zero is the dummy entry meaning no graph paper
unsigned long background;
unsigned long color1; // color for the major lines
unsigned long color2; // color for the minor lines
unsigned long color3; // color for the vellum lines, if any
int ncolors; // 1 or 2, unless this is the dummy entry which has 0 here
// 1 means there are no minor lines, only major lines
int nlines; // number of minor lines per major line
int spacingPoints; // spacing between major lines in printer's points (1/72 inch)
// must be an integer multiple of nlines
int thickness1; // thickness of major lines, in pixels
int 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 long titlebackgroundcolor;
unsigned long titlecolor;
unsigned long axescolor;
unsigned long 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 */
typedef struct {
int graphtype; /* ORDINARY, PARAMETRIC, POLAR, POLAR_CIRCULAR,
ODE, ODESYSTEM, ODE2, HDE, POLYROOT */
int numberofpoints; /* how many points to plot */
double linewidth; /* THICK or THIN */
unsigned long graphcolor;
unsigned long background; /* background color */
unsigned long fillcolor; /* used for inequalities */
unsigned long border; /* border color, if same as background then no border */
unsigned long axescolor; /* color for the tick labels too */
unsigned long axeslabelcolor; /* color for either numerical or symbolic labels */
unsigned long titlecolor;
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 grid: 1; /* should the grid be visible? */
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; /* zero means this is the first graph on
these axes; positive means it's a second
(or more) graph drawn on the same axes */
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;
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 */
int nsingularities; /* dimension of that array */
double **initial_values; /* array of pointers to initial values of ODE */
/* 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 */
unsigned newaxes:1; /* Next time we must redraw the 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 */
int *root_xcoords; /* arrays of pixel coordinates of roots */
int *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 */
unsigned spot; /* in Windows, an HBITMAP to the bitmap
used for polyroots */
int zoom_disabled; /* if zero, zooms will affect this graph */
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 long lamp1color; /* color of first lamp */
unsigned long 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