/* $Header: /afs/athena.mit.edu/astaff/project/atdev/src/fmax/RCS/interface.h,v 1.4 91/02/13 09:16:23 dot Exp Locker: dot $ */

/*
 * some important global things
 */
static Widget toplevel;
static AtPlotterWidget plotter;
static AtLabelWidget msgline;
static Widget cli;
static Widget helpShell;
static Widget help;
static Dialog *plotDialog;
static Dialog *barplotDialog;
static Dialog *axisDialog;
static Dialog *printDialog;
static Dialog *labelDialog;
static Dialog *plotterDialog;
static Cursor crosshair, crosshair2, waitcursor;

Fmaxplot *plotList;

static long numsamples = 100;

/* Function prototypes */
static void PlotHelp();
static void PlotterHelp();
static void CalcYValues(Tree *, Fmaxplot *);
static Fmaxplot *PlotExpression();
static Fmaxplot *addPlot(Tree *, int, Boolean);

/* External Functions */
extern void AtDialogResetCallback();
extern void removePlot();
extern Widget MuLookupWidget(char *);
extern void zoomout();
extern void m_zoomin();
extern void panright();
extern void panleft();
extern void pandown();
extern void panup();
extern void zoomin();

#define TOLERANCE 1e-05
#define clickmode_normal 1
#define clickmode_create 2
#define clickmode_edit 3
#define clickmode_delete 4
#define clickmode_movefrom 5
#define clickmode_moveto 6
#define MAXFILENAME 200
static int clickmode = clickmode_normal;

static DialogInfo PlotDialogInfo[] = {
{"title", AtDialogLABEL, 0, NULL},
{"namelabel", AtDialogLABEL, 0, NULL},
{"name", AtDialogTEXT, AtDialogRESOURCE, XtNlegendName},
{"connectpoints", AtDialogTOGGLE, AtDialogRESOURCE, XtNconnectPoints},
{"markpoints", AtDialogTOGGLE, AtDialogRESOURCE, XtNmarkPoints},
{"drawvertimpulses", AtDialogTOGGLE, AtDialogRESOURCE, XtNverticalImpulses},
{"drawhorizimpulses", AtDialogTOGGLE, AtDialogRESOURCE, XtNhorizontalImpulses},
{"linewidth", AtDialogINTOPTION, AtDialogRESOURCE, XtNlineWidth},
{"linestyle", AtDialogINTOPTION, AtDialogRESOURCE, XtNlineStyle},
{"dashlength", AtDialogINTOPTION, AtDialogRESOURCE, XtNdashLength},
{"marker", AtDialogINTOPTION, AtDialogRESOURCE, XtNmarker},
{"sep", AtDialogSEPARATOR, 0, NULL},    
{"apply", AtDialogPUSHBUTTON, 0, (char *)AtDialogApplyCallback},
{"done", AtDialogPUSHBUTTON, 0, (char *)AtDialogDoneCallback},
{"reset", AtDialogPUSHBUTTON, 0, (char *)AtDialogResetCallback}, 
{"help", AtDialogPUSHBUTTON, 0, (char *)PlotHelp},
};


static DialogInfo BarPlotDialogInfo[] = {
{"title", AtDialogLABEL, 0, NULL},
{"namelabel", AtDialogLABEL, 0, NULL},
{"name", AtDialogTEXT, AtDialogRESOURCE, XtNlegendName},
{"numpoints", AtDialogINTPARAMETER, AtDialogRESOURCE, XtNnumPoints},
{"xmin", AtDialogDOUBLEPARAMETER, AtDialogRESOURCE, XtNxMin},
{"xmax", AtDialogDOUBLEPARAMETER, AtDialogRESOURCE, XtNxMax},
{"density", AtDialogDOUBLEPARAMETER, AtDialogRESOURCE, XtNdensity},
{"shading", AtDialogTOGGLE, AtDialogRESOURCE, XtNshading},
{"pattern", AtDialogINTOPTION, AtDialogRESOURCE, XtNpattern},
{"sep", AtDialogSEPARATOR, 0, NULL},    
{"apply", AtDialogPUSHBUTTON, 0, (char *)AtDialogApplyCallback},
{"done", AtDialogPUSHBUTTON, 0, (char *)AtDialogDoneCallback},
{"reset", AtDialogPUSHBUTTON, 0, (char *)AtDialogResetCallback}, 
{"help", AtDialogPUSHBUTTON, 0, (char *)PlotHelp},
};

static void AxisHelp();

static DialogInfo AxisDialogInfo[] = {
{"title", AtDialogLABEL, 0, NULL},
{"min", AtDialogDOUBLEPARAMETER, AtDialogRESOURCE, XtNmin},
{"max", AtDialogDOUBLEPARAMETER, AtDialogRESOURCE, XtNmax},
{"transform",AtDialogSHORTOPTION, AtDialogRESOURCE, XtNtransform},
{"label", AtDialogLABEL, 0, NULL},
{"labeltext", AtDialogTEXT, AtDialogRESOURCE, XtNlabel},
{"fontfamily", AtDialogSTRINGOPTION, AtDialogRESOURCE, XtNlabelFontFamily },
{"fontsize", AtDialogINTOPTION, AtDialogRESOURCE, XtNlabelSize },
{"sep", AtDialogSEPARATOR, 0, NULL},
{"numberfont", AtDialogSTRINGOPTION, AtDialogRESOURCE, XtNnumberFontFamily},
{"numberfontsize", AtDialogINTOPTION, AtDialogRESOURCE, XtNnumberSize},
{"numberformat", AtDialogTEXT, AtDialogRESOURCE, XtNticFormat},
{"drawgrid", AtDialogTOGGLE, AtDialogRESOURCE, XtNdrawGrid},
{"autonumber", AtDialogTOGGLE, AtDialogRESOURCE, XtNautoNumber},
{"ticdensity", AtDialogSHORTPARAMETER, AtDialogRESOURCE, XtNticDensity},
{"subticdensity", AtDialogSHORTPARAMETER, AtDialogRESOURCE, XtNsubticDensity},
{"ticinterval", AtDialogDOUBLEPARAMETER, AtDialogRESOURCE, XtNticInterval},
{"subtics", AtDialogSHORTPARAMETER, AtDialogRESOURCE, XtNsubtics},
{"apply", AtDialogPUSHBUTTON, 0, (char *)AtDialogApplyCallback},
{"done", AtDialogPUSHBUTTON, 0, (char *)AtDialogDoneCallback},    
{"reset", AtDialogPUSHBUTTON, 0, (char *)AtDialogResetCallback}, 
{"help", AtDialogPUSHBUTTON, 0, (char *)AxisHelp},
};    

static DialogInfo PlotterDialogInfo[] = {
{"title", AtDialogLABEL, 0, NULL},
{"name", AtDialogTEXT, AtDialogRESOURCE, XtNtitle},
{"namelabel", AtDialogLABEL, 0, NULL},
{"fontfamily", AtDialogSTRINGOPTION, AtDialogRESOURCE, XtNlabelFontFamily },
{"fontsize", AtDialogINTOPTION, AtDialogRESOURCE, XtNlabelSize },
{"y2axis", AtDialogTOGGLE, AtDialogRESOURCE, XtNshowY2Axis},
{"framedaxes", AtDialogTOGGLE, AtDialogRESOURCE, XtNframedAxes},
{"rankChildren", AtDialogTOGGLE, AtDialogRESOURCE, XtNrankChildren},
{"floatingX", AtDialogTOGGLE, AtDialogRESOURCE, XtNfloatingX},
{"floatingY", AtDialogTOGGLE, AtDialogRESOURCE, XtNfloatingY},
{"showLegend",AtDialogTOGGLE, AtDialogRESOURCE, XtNshowLegend},
{"forceSquare", AtDialogTOGGLE, AtDialogRESOURCE, XtNforceSquare},
{"autoScale", AtDialogTOGGLE, AtDialogRESOURCE, XtNautoScale},
{"sep", AtDialogSEPARATOR, 0, NULL},    
{"apply", AtDialogPUSHBUTTON, 0, (char *)AtDialogApplyCallback},
{"done", AtDialogPUSHBUTTON, 0, (char *)AtDialogDoneCallback},
{"reset", AtDialogPUSHBUTTON, 0, (char *)AtDialogResetCallback}, 
{"help", AtDialogPUSHBUTTON, 0, (char *)PlotterHelp},
};

static double printwidth = 8;
static double printheight = 5;
static char printname[100] = "";
static int printto = 0;
static int printunits = 0;
static int printorientation = 1;

static void PrintCallback();
static void PrintHelp();

static DialogInfo PrintDialogInfo[] = {
{"title", AtDialogLABEL, 0, NULL},
{"printername", AtDialogLABEL, 0, NULL},
{"printernametext", AtDialogTEXT, AtDialogCOPYSTRING, printname},
{"printto", AtDialogINTOPTION, AtDialogABSOLUTE, (char *)&printto},
{"width", AtDialogDOUBLEPARAMETER, AtDialogABSOLUTE,(char *)&printwidth},
{"height",AtDialogDOUBLEPARAMETER,AtDialogABSOLUTE,(char *)&printheight},
{"units", AtDialogINTOPTION, AtDialogABSOLUTE, (char *)&printunits},
{"orientation", AtDialogINTOPTION, AtDialogABSOLUTE,(char *)&printorientation},
{"sep1", AtDialogSEPARATOR},    
{"print", AtDialogPUSHBUTTON, 0, (char *)PrintCallback},
{"cancel", AtDialogPUSHBUTTON, 0, (char *)AtDialogDoneCallback},    
{"reset", AtDialogPUSHBUTTON, 0, (char *)AtDialogResetCallback},
{"help", AtDialogPUSHBUTTON, 0, (char *)PrintHelp},
};

static void AnnotateOk();

static DialogInfo LabelDialogInfo[] = {
{"title", AtDialogLABEL},
{"label", AtDialogLABEL},
{"labeltext", AtDialogTEXT, AtDialogRESOURCE, XtNlabel},
{"font", AtDialogSTRINGOPTION, AtDialogRESOURCE, XtNfontFamily},
{"size", AtDialogINTOPTION, AtDialogRESOURCE, XtNfontSize},
{"just", AtDialogINTOPTION, AtDialogRESOURCE, XtNjustify},
{"pos", AtDialogTOGGLE, AtDialogRESOURCE, XtNfloatingPosition},    
{"sep", AtDialogSEPARATOR},
{"ok", AtDialogPUSHBUTTON, 0, (char *)AnnotateOk},
{"cancel", AtDialogPUSHBUTTON, 0, (char *)AtDialogDoneCallback},    
{"help", AtDialogPUSHBUTTON, 0, NULL},
};

#define is_comment(c) ((c) == '#')
