/* * GRAPH, Version 1.00 - 4 August 1989 * * Copyright 1989, David Gay. All Rights Reserved. * This software is freely redistrubatable. */ /* class function, inherits from class object. The actual function types are su b-classes of this one */ #ifndef FUNCTION_H #define FUNCTION_H #include "list.h" #include "object.h" #include "graph.h" #include "user/eval.h" #include #define MAXERROR 0.2 /* For discontinuities */ #define MAXITER 4 /* In improvement algo */ #define FLAT 2 /* number of pixels allowed in "flat" discontinuities */ #define DEFSTEPS 100 /* Default number of steps */ #define FDIST 5 /* Max (y) distance for function select */ /* class function (inherited from class object). Fields are public. */ struct function { struct object o; int (*calcf)(struct function *this, int allow_mes); /* Recalculate values o f points */ int (*save)(struct function *this, FILE *f); /* Save function specif ic info. to file */ /* Information global to all types of functions */ char vname[VARLEN]; /* name of variable */ double min, max; /* Limits for variable */ int steps; /* Number of points to calculate */ BYTE colour; /* Colour in which to draw */ int showdisc : 1; /* Show discontinuities ? */ int nicedisc : 1; /* Allow "nice" discontinuities */ /* State info */ int calc : 1; /* Points calculated ? */ int selected : 1; /* function selected ? */ variable var; /* Actual variable */ var_list used; /* Vars this function depends on */ list pts; /* Points composing this, different structure for each type of function */ size_t sizept; /* Size of one point (for delete) */ }; /* Flags for point state */ #define EXISTS 1 /* Function is defined here */ #define DISC 2 /* This is a discontinuity */ #define OK 4 /* All is well */ /* The base class for a point */ struct point { node node; char state; double x, y; }; typedef struct point point; /* Create/load the various types of function */ struct f_of_x *new_f_of_x(struct graph *g, char *name); struct x_y *new_x_y(struct graph *g, char *name); struct r_of_t *new_r_of_t(struct graph *g, char *name); struct r_t *new_r_t(struct graph *g, char *name); struct f_of_x *load_f_of_x(struct graph *g, FILE *f); struct x_y *load_x_y(struct graph *g, FILE *f); struct r_of_t *load_r_of_t(struct graph *g, FILE *f); struct r_t *load_r_t(struct graph *g, FILE *f); /* A few useful functions ... */ void display_function(struct function *this); /* Draws a function */ void init_function(struct function *this, struct graph *g, char *name); /* Stan dard init. */ int load_rest(struct function *this, FILE *f); /* Load public part of function */ #endif