Sindbad~EG File Manager

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

/* M. Beeson, for MathXpert.
Original date 5.31.94
Last modified 4.7.96
10.7.04 added "problemnumbers" to doc data.
1.18.06 added the papyrus field to the document
1.19.06 pasted papyrus.h into this file
3.17.06 removed repeated typedef int coord
9.2.07 changed 'short' to 'int' throughout
1.21.11 added 'totalautosteps'
12.12.23  unit changed to heapunit; added UTHASH

Specification of the data private to a MathXpert document.
There are two types of documents: graph documents and symbol documents.
However, since we need all the symbolic apparatus while making
graphs, in order to calculate singularities for example, we
use only one type of document data structure.
*/
#ifndef COORD
typedef int coord;  // duplicate definition in display.h
#define COORD
#endif

#include <time.h>

#ifndef UTHASH
  #include "uthash.h"
  #define UTHASH
#endif

#define MAXDOCUMENTS 2   /* maximum number of simultaneously-open documents per user */
#define GRAPHDOC 0
#define SYMBOLDOC 1
#define GRAPHDOC3D 2
#define MAXGRAPHS 6     /* maximum number of graph lines     */
#define NFINDITFAST 5  /* dimension of the find-it-fast menu */
#define MAXFINALREMARK 1024  /* final remark can be long! */
#define MAXHINTS 400

#define SOURCE_USER     1
#define SOURCE_MATHPERT 0
#define SOURCE_FILE     3

#define MAXHOMEWORKS (MAXDOCUMENTS + 1)

#include "cflags.h"    /* MAXPATHLENGTH */
#include "coord.h"
#include "displaycontrol.h"
#include "errbuf.h"
 
#define REASONLINE 29   /* papyrus->reasons is set to start reasons
                           this multiple of 16 from the right of the papyrus. */
#define MAX_SESSIONID 33  /* 32 characters and a terminator */

/*_______________________________________________________________________*/
/* The following data structure (Papyrus) is associated to a symbolic
document, but is not saved when the document is saved.  When a saved
document is opened, this structure must be created again; it may
be different if the document is opened on a different machine or
even in a different window.  */

/* First we need a structure to specify the location of a single line.
The YPAIRs specify the top and bottom of the components of the line
in papyrus coordinates */

typedef struct { coord x;
                 coord y;
               } YPAIR;

typedef struct { YPAIR formula;
                 YPAIR reasonrect;
                 YPAIR comment;
               } line;  /* 12 bytes per line */

typedef struct
{ int cxChar;      /* horizontal pixels corresponding to 16 papyrus coordinate units */
  int cyChar;      /* height of current font in pixels */
                   /* That is, pixels corresponding to 16 vertical papyrus coordinate units */
  int width;     /* of papyrus, in papyrus coordinates */
  int height;    /* of papyrus, in papyrus coordinates. Measures area on which lines are written,
                      not including any blank area below the solution-so-far. */
  int top;       /* of window, in papyrus coordinates  */
  int left;      /* of window, in papyrus coordinates  */
  int right;     /* of window, in papyrus coordinates  */
  int bottom;    /* of window, in papyrus coordinates. Note this corresponds to
                      the bottom of the window, not the bottom of the window
                      minus the bottommargin.  */
  int clientRight;  /* client coordinates of the right of the solution window */
  int clientBottom; /* the top and left will always be zero     */
  int leftmargin;/* x coordinate at which formulas begin */
  int rightmargin; /* how far left of pPapyrus->right the formulas will break;
                        but + signs in a sum can occur to the right of here */
  int topmargin; /* y coordinate at which formulas begin */
  int bottommargin;  /* leave this much room at the bottom of the window below the
                          last displayed formula. */
  int reasonstart;   /* x-coordinate at which justifications begin */
  line *lines;     /* array of pointers to line, of dimension nlines*/
  int nlines;    /* dimension of the lines array        */
  void *selected;  /* linked list of subterms of the active line currently selected by user */
                   /* making it void * enables compiling without lterm.h */
  int selectedline;  /* history[selectedline] is the line from which the
                        selected terms are chosen  */
  char finalremark[MAXFINALREMARK];  /* final remark stored here so it travels with the document */
  char hint[MAXHINTS];   /* If there is a hint, it goes here */
  char comment_buffer[DIM_COMMENT_BUFFER][COMMENTBUFLENGTH];
  char error_buffer[DIM_ERROR_BUFFER][ERRBUFLENGTH];
} Papyrus;
 
typedef struct
   { const char *reason;
     unsigned char *comment;
     unsigned char controlflags;
     unsigned int eigenindex;  /* index of eigenvariable in varlist */
   } linedata;

/*_______________________________________________________________________*/
typedef struct
 { unsigned mathmode:3;
   unsigned display_on:1;     /* zero means display is off, e.g. for think_ahead */
   unsigned memoryflag:1;     /* whether display of available heap is on   */
   unsigned complex_frozen:1; /* can user turn complex on/off?     */
   unsigned checksolutionsflag:1;
   unsigned substitutionflag:1;
   unsigned logcollectflag:1;
   unsigned comdenomflag:1; /* documented in autosimp.c             */
   unsigned linebreaks:1;   /* set if linebreaks are desired        */
   unsigned nfailedops:2;   /* number of valid entries in failedops array */
   int radicalflag:3;  /* documented in autosimp.c             */
   unsigned finishedflag:1; /* means automode can't do more */
   unsigned solvedflag:1;   /* means the problem is solved  */
   unsigned  assumptions_visible:1;
   unsigned  definitions_visible:1;
   int expandflag;
   int trigexpandflag; /* documented in autosimp.c            */
   int factorflag;     /* controls factoring in auto mode; defined in automode.c */
   int selected_equation;
   /*  int problemtype;   eliminated 12.31.24 in favor of pDocData->problemtype  */
   int currenttopic;
   term minmax_interval;
   assumption *pending; /* used in integration by subst */
   hashbucket model[HASHPRIME];  /* user model for this document */
   inhibition *inhibitions;   /* header of the linked list of inhibitions */
   int successivefailures;    /* number of wrong operator choices in a row
                                 without success either in menu or auto mode */
   int localfailures;        /* number of wrong operator choices on this problem */
   int autosteps;            /* count successive steps in automode */
   int totalautosteps;       /* total number of steps done in automode */
   int totalsteps;           /* total number of steps taken, autostep, showstep, term selection */
                             /* undo does not reduce totalsteps or totalautosteps but does reduce autosteps */
   operation *opseq;          /* history of operator use  */
   actualop failedops[4];
   linedata *linedatahistory;   /* reason, comment, and control flag history */
   unsigned nlinedata;              /* dimension of the above array */
   operation plan[NFINDITFAST];   /* operators automode thinks should be used next */
   int showstepflag;              /* set to 1 while showstep is running */
 } controldata;

/*_______________________________________________________________________*/

typedef struct docdata        /* data local to a document           */
  { /* Document control________________________________________*/
    unsigned kind:2;          /* SYMBOLDOC, GRAPHDOC, 3DGRAPHDOC  */
    unsigned problemsource:6;  /* SOURCE_MATHPERT, SOURCE_USER */
                   /*  SOURCE_FILE, SOURCE_TEXTBOOK not supported by the Engine */
    unsigned language: 8;     /* ENGLISH, FRENCH, etc. */
    int docnumber;
    int problemtype;
    int currenttopic;
    char sessionId[MAX_SESSIONID];     // key for hashing this structure
    UT_hash_handle hh;   //  makes this structure hashable
    time_t lastMessageTime;  // so we can delete abandoned documents
    int version;    /*  102 for version 1.02  */
    Papyrus *papyrus;        /* structure that assists in display of formulas */
    term *progress;  /* array to accumulate trial factors or trial integrate-by-parts terms */
    const char *progressTitle;     /*  "Trying factors"  for example, title to use with progress */
    int creator;  /* nonzero means created by graph button on a symbolic view window */
    int nextProgress;  /* how many terms are stored in progress at the moment */
    unsigned textweight:1;   /* 1 means boldface */
    unsigned initialized:1;  /* set when the document has been initialized */
    unsigned problemready:1;
    
    /* Control variables--these control auto mode_____________ */
    controldata DocControlData;

    /* Polyval control flags __________________________________*/
    polyflags DocPolyData;  /* see polyval.h  */
    /* including infractionflag, arithflag, complex, orderflag */

    /* Display data___________________________________________*/
    display_control DocDisplayControlData;

    /* Memory management_______________________________________*/
    heapunit *heap;
    unsigned heapsize;  /* in 'units', see heap.c              */

    /* Variables________________________________________________*/
    vardata DocVarData;
       /* varlist, varinfo, parameters, defns,
          nvariables, eigenvariable, maxvariables;
          nparameters, maxparameters, maxdefns, nextdefn;
          currentline
       */
   /* Homework file_____________________________________________*/
   int homework[MAXHOMEWORKS];    /* indices of the homework structures
                                     to use with each choice of 'source' */
                                  /* homework structures are defined in wfile.h */
   int problemnumbers[MAXHOMEWORKS];   /* problem numbers in each homework structure, indexed by source */
                  /* thus problemnumbers[SOURCE_MATHPERT] is the current problem number for SOURCE_MATHPERT
                     even though that corresponds to homework[1],  while SOURCE_MATHPERT is 0.   */

    /* Assumptions and theorems_________________________________*/
    proverdata DocProverData;
    /* assumptions, maxassumptions, nextassumption,
       theorems, maxtheorems, nexttheorem,
       history, maxhistory, (but not currentline)
       succedent, workspace, maxworkspace, nextworkspace,
       and solver  (function pointer to an equation solver)
    */

    /*Graphs____________________________________________________*/
    
    int symboltopic;
    int graphtopic;
    int graphproblemtype;  /* If the Graph button is pushed, this is set */
    int symbolproblemtype;
    int showGraphButton;   /* if 0, GraphButton will not be shown  */
   
    int mainchoice;/* which type of graph(s) to draw            */
           /* possible values of mainchoice are in mainchoi.h   */
    term function;      /* function or functions to be graphed;
                           if there are several this will be a
                           term with functor AND                */
    graph *graphs[MAXGRAPHS]; /* One for each graph line        */
    long display3d;    /* RenderLib display for 3d graphs */
    long viewport3d;   /* RenderLib viewport for 3d graphs */
    int ngraphs;        /* used dimension of the graphs array   */
    /* WebMathXpert doesn't support user-defined functions,
       but we didn't remove the following code */
    /* User-defined functions____________________________________*/
    /* These are shared between documents but still need to be saved  */
    int nuserfunctions;
    char **defns;   /* array of nuserfunctions definitions, each of form lhs = rhs  */
  } DOCDATA;

typedef DOCDATA *PDOCDATA;

#define PGRAPHDATA PDOCDATA
#define PSYMBOLDATA PDOCDATA
#define SYMBOLDATA DOCDATA
#define GRAPHDATA  DOCDATA



/* Each document gets an identifying number, stored in the
docnumber field.  These are never re-used in a given session,
even if documents are closed.  When a document is restored
from disk, it is given a new document number.  */

 /* 'ringflag' controls what kind of factors will be sought in auto mode.
    Do we want:  (bit 0 = 0)  integer factors (clearing denoms first)
                 (bit 0 = 1)  rational factors ok
                 (bit 4 = 0)  complex factors not wanted
                 (bit 4 = 1)  complex factors ok
                 (bit 8 = 0)  algebraic factors like (x- sqrt 3) not wanted
                 (bit 8 = 1)  algebraic factors ok
    The following #-defined constants are used to set the value of ringflag:
 */
#define INTRING 0x0000
#define RATRING 0x0001
#define GAUSSINT 0x0010
#define GAUSSRAT 0x0011
#define ALGINT 0x0100
#define REALRING  0x0101
#define COMPLEXALGINT 0x0110
#define COMPLEXRING  0x0111

/*_______________________________________________________________________*/
/* MathXpert has global variables corresponding to the fields of a
document.  These are called 'document globals'.   The functions
active and deactivate translate between these
variables and the 'document internals', or fields of the document
data structure. */

void activate(PDOCDATA);      /* called under WM_MDIACTIVATE */
void deactivate(PDOCDATA);    /* called under WM_MDIACTIVATE when deactivating */
int init_doc_data(int, PDOCDATA);
void destroy_document_data(PDOCDATA pDocData);
int needsGraphButton(PDOCDATA pDocData);

#define ASCENDING 1
#define DESCENDING 0   /* values of 'orderflag'  */
#define VISIBLESUBS 1    /* values of substitutionflag */
#define INVISIBLESUBS 0

void set_controldata(controldata *);  /* defined in cflags.c */
void get_controldata(controldata *);

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