/*
 * $Id: SPlot.h,v 1.0 91/08/22 15:34:06 gnb Exp $ 
 * $Source: /export/data/sources/x/At/Plotter/RCS/SPlot.h,v $
 * 
 * $Log:	SPlot.h,v $
 * Revision 1.0  91/08/22  15:34:06  gnb
 * Initial revision
 * 
 * 
 */

/*

Copyright 1991 by Burdett, Buckeridge & Young Ltd.

All rights reserved.

Permission to use, copy, modify, and distribute this software and its
documentation for any purpose and without fee is hereby granted,
provided that the above copyright notice appear in all copies and that
both that copyright notice and this permission notice appear in
supporting documentation, and that the name of Burdett, Buckeridge &
Young Ltd. (BBY) not be used in advertising or publicity pertaining to
distribution of the software without specific, written prior
permission.

BBY DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
BBY BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
SOFTWARE.

*/
/*
 * AtSPlot is  non-instanced class that contains resources and routines
 * for accessing data that is currently stored in an array of
 * structures.
 */

#ifndef _AtSPlot_h
#define _AtSPlot_h

#include <X11/Intrinsic.h>
#ifdef _AtDevelopment_
#include "Plot.h"
#else
#include <At/Plot.h>
#endif

typedef enum { AtDouble, AtFloat, AtInt } AtDataType;

/* declare specific AtSPlotWidget class and instance datatypes */

typedef struct _AtSPlotClassRec*	AtSPlotWidgetClass;
typedef struct _AtSPlotRec*		AtSPlotWidget;

/* declare the class constant */

extern WidgetClass atSPlotWidgetClass;

#ifndef P
# ifdef __STDC__
#  define P(args) args
# else
#  define P(args) ()
# endif
#endif

/*
 * The "member" routine to attach the data.  The subclasses of AtSPlot
 * export a #define for this routine.
 */
extern void AtSPlotAttachData P((AtSPlotWidget, XtPointer data,
				 AtDataType type, Cardinal stride,
				 Cardinal start, Cardinal num));

extern void AtSPlotExtendData P((AtSPlotWidget, Cardinal num));

/*
 * Get the i'th value from the AtSPlot data.  This declares the function
 * version, a macro is available below.  This is intended mainly for
 * subclasses of AtSPlot, but applications may find it useful.
 */
extern double AtSPlotGetValue P((AtSPlotWidget, Cardinal));

/*
 * A macro version of the above.  May be faster, but death to debug!
 */

/* First, get the address of the i'th element */
#define _sp_ptr(p, i) ((XtPointer)((char *)p->splot.data + \
				   p->splot.stride * (i)))

#define AtSPlotGetValue(p, i) \
     ((double) \
      ((p)->splot.type == AtDouble ? *((double *)_sp_ptr((p), (i))) : \
       (p)->splot.type == AtFloat ? (double)*((float *)_sp_ptr((p), (i))) : \
       (p)->splot.type == AtInt ? (double)*((int *)_sp_ptr((p), (i))) : 0.0))

#endif /* _AtSPlot_h */
