#ifndef _PlotP_h
#define _PlotP_h

#include <X11/CompositeP.h>
#include "Plot.h"

/**********************************************************************
 *
 *   Plot Widget Class Definitions
 *
 **********************************************************************/

#define XtRDouble               "double"

typedef struct {
  GC          gc1, gc2, gc3, pointerGC;
  XFontStruct *small_font;
  Cursor      pointer_cursor, plotwin_cursor;
} PlotClassPart;

typedef struct {
  CoreClassPart      core_class;
  CompositeClassPart composite_class;
  PlotClassPart      plot_class;
} PlotClassRec;

extern PlotClassRec plotClassRec;

/**********************************************************************
 *
 *   Plot Widget Definitions
 *
 **********************************************************************/


typedef struct {
  /* accessible from resources */
  Pixel color1, color2, color3, foreground, background, plotback;
   /* Colors of three plot lines, general background and plot bkground */
  char *title;          /* title of entire plot (unused at present) */
  double paperSpeed;    /* for stripchart: in cm/sec on screen */
  double decayTime; /* length of time an X-Y plot pixel stays before erasure */
  int placeX, place1, place2, place3; /* variables place codes for all axes */
  int typeX, type1, type2, type3;     /* variable type codes */
  char *labelX, *label1, *label2, *label3; /* axis names */
  char *unitX, *unit1, *unit2, *unit3;
  double minX, min1, min2, min3; /* all minimum values */
  double maxX, max1, max2, max3; /* all max values */
  Boolean autoX, auto1, auto2, auto3; /* autoscalable flags */
  Boolean stripMode; /* True = scrolling stripchart, False = oscilliscope */
  unsigned int timing;/* =0: continuous plot, = other codes: 1 pt of cycle */

  /* private state */
  XtCallbackList callbacks;
  int plotWidth, plotHeight; /* inner plot size, calculated */
  int titlePad, labelPad; /* amount of space around top and bottom */
  int xoff; /* x-axis position for pointer plot position string. */
  double currentTime;
  double sfX, sf1, sf2, sf3;     /* all computed scale factors data->pixel */
  int slideDots; /* number of pixels per slide operation in stripchart */
  int nextHash; /* next place to get a time tic in stripchart (time) mode */
  int lastPtX, lastPt1, lastPt2, lastPt3; /* last pixels plotted */
  int phase2, phase3; /* Dash phase position. */
  int outX, out1, out2, out3;
  double lastX, last1, last2, last3;
  double sumX, sum1, sum2, sum3;
  unsigned int cntX, cnt1, cnt2, cnt3;
  Window plotwin;/* inner window where plotting is going on. */
  Drawable plotpix; /* background pixmap of plotwin, contains actual plot */
  Widget label1w, label2w, label3w; /* Label widgets */
  Widget refreshButton, modButton; /* active command buttons */
} PlotPart;

typedef struct {
  CorePart      core;
  CompositePart composite;
  PlotPart      plot;
} PlotRec, *PlotWidget;

#endif
