
/* 
 * Structure defs and tidbits needed for xplot and its manipulating routines
 */

#include <sys/types.h>
#include <X11/Xos.h>
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#define XK_LATIN1
#include <X11/keysymdef.h>
#include <X11/Intrinsic.h>

/*
 * xpwmap is used by xplot to keep track of this guys map into world 
 * space
 */
struct xpwmap {
	float Sz;				/* Scales */
	float Sx;
	float Sy;			
	float world_mat[4][4];	/* world matrix for this object */
	int first;				/* clue for xplot (0=1st, 1=!1st )*/
};

/*
 * This structure is passed to xplot.  It must be filled in by the 
 * caller.
 *
 *
 * Format of the data files is a follows.
 * if plotting (X,Y) data:  [3 values/graph, 2 graphs]
 *       (Graph 1)
 *      data[0] = X1.0;			-- Y data is assumed sequential 
 *      data[1] = X1.1;
 *      data[2] = X1.2;
 *       (Graph 2)
 *      data[3] = X2.0;			
 *      data[4] = X2.1;
 *      data[5] = X2.2;
 *
 *
 * if plotting (X,Y,Z) data:	[3 points/graph, 2 graphs]
 *         (Graph 1)
 * 		data[0]  = X1.0;
 * 		data[1]  = Y1.0;
 * 		data[2]  = Z1.0;
 * 		data[3]  = X1.1;
 * 		data[4]  = Y1.1;
 * 		data[5]  = Z1.1;
 * 		data[6]  = X1.2;
 * 		data[7]  = Y1.2;
 * 		data[8]  = Z1.2;
 *         (Graph 2)
 * 		data[9]  = X2.0;
 * 		data[10] = Y2.0;
 * 		data[11] = Z2.0;
 * 		data[12] = X2.1;
 * 		data[13] = Y2.1;
 * 		data[14] = Z2.1;
 * 		data[15] = X2.2;
 * 		data[16] = Y2.2;
 * 		data[17] = Z2.2;
 *
 */

struct xpinfo {
	Window plot;		/* X window # */
	Display *dpy;		/* X Display # (for X11) */
	GC gc;				/* gc for X11 */
	XFontStruct *font;	/* font */
	int backPixel;		/* X stuff */
	int forePixel;		/* X stuff */
	int Window_X;		/* X dimension of window in pixels (512 is nice) */
	int Window_Y;		/* Y dimension of window in pixels (512 is nice) */		
	int Window_Z;		/* Z dimension of window in pixels (512 is nice) */
	float *data;		/* array of data (format depends on if xyz data) */
	int doxyz;			/* 0 = only Z data, 1 we have x y and z data */
	int numgraphs;		/* Number of graphs we are given */
	int numz;			/* Number of Z values per graph */
	float min_x;		/* Minimum X value (used to control scaling in window)*/
	float max_x;		/* Maximum X value */
	float min_y;		
	float max_y;		
	float min_z;		
	float max_z;		
	float Xtheta;		/* X rotation in degreees */
	float Ytheta;		/* Y rotation in degreees */
	float Ztheta;		/* Z rotation in degreees */
	int X_scale;		/* X scale of obj relative to window(.5 = 1/2 window)*/
	int Y_scale;		/* X scale of obj relative to window(.5 = 1/2 window)*/
	int Z_scale;		/* X scale of obj relative to window(.5 = 1/2 window)*/
	int flags;			/* Generic space for calling routine to use */
	struct xpwmap wmap;	/* stucture containing world map info */
};

/*
 * Globals used by xplot 
 */

extern	int 	dontplot;
extern	int 	dodraw;
extern	int 	doaxis;
extern 	char	programname[];

#define DX 		0
#define DY 		1
#define DZ 		2
#define DS		3

#define MAXGRAPHS 1024
#define RAD(x)	((float)x/360 * 2 * PI)
#define PI 		3.14159

