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

/*

Copyright 1990,1991 by the Massachusetts Institute of Technology

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 the Massachusetts
Institute of Technology (M.I.T.) not be used in advertising or publicity
pertaining to distribution of the software without specific, written
prior permission.

M.I.T. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
M.I.T. 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.

*/
#ifndef _PlotterP_h
#define _PlotterP_h    

#include <X11/IntrinsicP.h>
#include <X11/ConstrainP.h>

#ifdef _AtDevelopment_
#include "Plotter.h"
#include "Text.h"
#include "AxisCore.h"
#else
#include <At/Plotter.h>
#include <At/Text.h>
#include <AxisCore.h>
#endif

typedef struct ranking{ /* A private data structure */
     AtPlotWidget	child;
     int		rank_order;
     struct ranking *prev;
     struct ranking *next;
} Rank;

typedef struct {
     double	xmin, xmax;
     double	x2min, x2max;
     double	ymin, ymax;
     double	y2min, y2max;
} AtPlotterBoundingBox;
    
/*
 * All these coords are with 0,0 in top left.  This is the opposite
 * to the intuitive graph numbering, so some care is definitly required....
 *
 * The Y axis is along the LH edge, the Y2 axis the RH edge, the X
 * axis is bottom, X2 axis is the top.  Point (x1,y1) is top LH
 * corner, (x2,y2) is bottom RH corner.
 *
 */
typedef struct {
     short	x1, y1, x2, y2;		/* the plotting area */
     short	width, height;		/* the size of same */
     short	title_x, title_y;	/* where the title goes */
     short	legend_x, legend_y; 	/* where the legend goes */
     short	legend_width, legend_height; /* Size of legend */
} AtPlotterLayout;

typedef struct _AtPlotterPart {    
     /* resources */
     String	font_family;
     String	title;
     String	legend_title;
     int	title_size;
     int	legend_title_size;
     int	legend_size;
     int	title_style;
     int	legend_title_style;
     int	legend_style; 
     Pixel	title_color;
     Pixel	legend_color;
     Boolean	show_legend;
     short	default_legend_width;
     short	legend_spacing;
     short	margin_width;
     short	margin_height;
     Boolean	rank_children;
     
     /* 
      * Private widgets.  All are also children of this widget.
      */ 
     
     AtAxisCoreWidget	xaxis;
     AtAxisCoreWidget	yaxis;
     AtAxisCoreWidget	x2axis;
     AtAxisCoreWidget	y2axis;
     
     /* private state */
     
     Rank		*ordered_children; /* rank ordered list of all children */
     AtFontFamily	*ff;
     GC			titleGC, legendGC, dragGC;
     AtText		*title_text;
     AtText		*legend_title_text;
     AtPlotterLayout	layout;
     AtPlotterBoundingBox	bounding_box; /* As accepted by the axes */
     AtPlotterBoundingBox	raw_bounding_box; /* Raw from plot data */
     
     /* The state for the redraw processing */
     Boolean expose_requested;
     
     Boolean	redraw_required;
     Boolean	rescale_required;
     Boolean	layout_required;
     Boolean	in_layout_mode; /* Help stop infinite loops! */
} AtPlotterPart;

typedef struct _AtPlotterRec {
     CorePart		core;
     CompositePart	composite;
     ConstraintPart	constraint;
     AtPlotterPart	plotter;
} AtPlotterRec;

typedef struct _AtPlotterClassPart {
     int			peek_a_boo;
} AtPlotterClassPart;

typedef struct _AtPlotterClassRec {
     CoreClassPart	core_class;
     CompositeClassPart	composite_class;
     ConstraintClassPart	constraint_class;
     AtPlotterClassPart	plotter_class;
} AtPlotterClassRec;

extern AtPlotterClassRec atPlotterClassRec;

/*
 * A linked list of from,to pairs for the extended list
 */
typedef struct _ExtendedList {
     struct _ExtendedList *next;
     int	from, to;
} ExtendedList;

typedef struct _AtPlotterConstraintsPart {
    /* resources */
    Boolean	displayed;
    String	legend_name;
    Boolean	use_x2_axis;
    Boolean	use_y2_axis;
    int		rank_order;

    /* private	state */
    AtText	*legend_text;
    BoundingBox	bounding_box;

    /* This is the state kept for the redraw routine */
    Boolean	needs_refresh;
    ExtendedList *extended_list; 
} AtPlotterConstraintsPart;

typedef struct {
     AtPlotterConstraintsPart	plotter;
} AtPlotterConstraintsRec, *AtPlotterConstraints;


#endif
