1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185
|
/*
* bltGrElem.h --
*
* Copyright 1991-1998 Lucent Technologies, Inc.
*
* 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 the copyright notice and warranty
* disclaimer appear in supporting documentation, and that the names
* of Lucent Technologies any of their entities not be used in
* advertising or publicity pertaining to distribution of the software
* without specific, written prior permission.
*
* Lucent Technologies disclaims all warranties with regard to this
* software, including all implied warranties of merchantability and
* fitness. In no event shall Lucent Technologies 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 tortuous action, arising
* out of or in connection with the use or performance of this
* software.
*/
#ifndef _BLT_GR_ELEM_H
#define _BLT_GR_ELEM_H
#define ELEM_CLOSEST_XY 0
#define ELEM_CLOSEST_X 1
#define ELEM_CLOSEST_Y 2
/*
* The data structure below contains information pertaining to a line vector.
* It consists of an array of floating point data values and for convenience,
* the number and minimum/maximum values.
*/
typedef struct ElemVector {
Blt_Vector *vecPtr;
double *valueArr;
int nValues;
int arraySize;
double min, max;
Blt_VectorId clientId; /* If non-NULL, a client token identifying the
* external vector. */
Element *elemPtr; /* Element associated with vector. */
} ElemVector;
/*
* An element has one or more vectors plus several attributes, such as line
* style, thickness, color, and symbol type. It has an identifier which
* distinguishes it among the list of all elements.
*/
typedef struct ClosestSearch ClosestSearch;
typedef void (ElemDrawProc) _ANSI_ARGS_((Graph *graphPtr, Drawable drawable,
Element *elemPtr));
typedef void (ElemPrintProc) _ANSI_ARGS_((Graph *graphPtr, Printable printable,
Element *elemPtr));
typedef void (ElemDestroyProc) _ANSI_ARGS_((Graph *graphPtr, Element *elemPtr));
typedef int (ElemConfigProc) _ANSI_ARGS_((Graph *graphPtr, Element *elemPtr));
typedef void (ElemMapProc) _ANSI_ARGS_((Graph *graphPtr,
Element *elemPtr));
typedef void (ElemExtentsProc) _ANSI_ARGS_((Element *elemPtr,
Extents2D *extsPtr));
typedef void (ElemClosestProc) _ANSI_ARGS_((Graph *graphPtr, Element *elemPtr,
ClosestSearch *searchPtr));
typedef void (ElemDrawSymbolProc) _ANSI_ARGS_((Graph *graphPtr,
Drawable drawable, Element *elemPtr, int x, int y, int symbolSize));
typedef void (ElemPrintSymbolProc) _ANSI_ARGS_((Graph *graphPtr,
Printable printable, Element *elemPtr, int x, int y, int symbolSize));
typedef struct ElementClass {
Tk_ConfigSpec *configSpecs; /* Configuration specifications */
ElemClosestProc *closestProc;
ElemConfigProc *configProc;
ElemDestroyProc *destroyProc;
ElemDrawProc *drawActiveProc;
ElemDrawProc *drawNormalProc;
ElemDrawSymbolProc *drawSymbolProc;
ElemExtentsProc *extentsProc;
ElemPrintProc *printActiveProc;
ElemPrintProc *printNormalProc;
ElemPrintSymbolProc *printSymbolProc;
ElemMapProc *mapProc;
} ElementClass;
struct Element {
char *name; /* Identifier to refer the element.
* Used in the "insert", "delete", or
* "show", commands. */
ObjectType type; /* Type of element; either
* TYPE_ELEM_BAR, TYPE_ELEM_LINE, or
* TYPE_ELEM_STRIP */
Graph *graphPtr; /* Graph widget of element*/
unsigned int flags; /* Indicates if the entire element is
* active, or if coordinates need to
* be calculated */
char **tags;
int hidden; /* If non-zero, don't display the element. */
Tcl_HashEntry *hashPtr;
char *label; /* Label displayed in legend */
int labelRelief; /* Relief of label in legend. */
Axis2D axes; /* X-axis and Y-axis mapping the element */
ElemVector x, y, w; /* Contains array of floating point
* graph coordinate values. Also holds
* min/max and the number of
* coordinates */
int *reqActiveArr; /* Array of indices (malloc-ed) which
* indicate which data points are
* active (drawn with "active"
* colors). */
int reqNumActive; /* Number of active data points.
* Special case: if reqNumActive < 0
* and the active bit is set in
* "flags", then all data points are
* drawn active. */
ElementClass *classPtr;
};
#define COORDS_NEEDED (1<<0) /* Indicates that the element's
* configuration has changed such that
* its layout of the element (i.e. its
* position in the graph window) needs
* to be recalculated. */
#define ELEM_ACTIVE (1<<8) /* Non-zero indicates that the element
* should be drawn in its active
* foreground and background
* colors. */
#define ELEM_UPDATE_ACTIVE (1<<7)
#define LABEL_ACTIVE (1<<9) /* Non-zero indicates that the
* element's entry in the legend
* should be drawn in its active
* foreground and background
* colors. */
struct ClosestSearch {
int halo; /* Maximal distance a candidate point
* can be from the sample window
* coordinate */
int interpolate; /* If non-zero, find the closest point
* on the entire line segment, instead
* of the closest end point. */
int x, y; /* Screen coordinates of test point */
double dist; /* Distance in screen coordinates */
/* Output */
Element *elemPtr; /* Name of the closest element */
Point2D point; /* Graph coordinates of closest point */
int index; /* Index of closest data point */
int along; /* Indicates to let search run along a
* particular axis: x, y, or both. */
};
typedef struct PenStyle {
Pen *penPtr; /* Pen to draw */
Range weight; /* Range of weights */
} PenStyle;
extern double Blt_FindElemVectorMinimum _ANSI_ARGS_((ElemVector *vecPtr,
double minLimit));
extern void Blt_ResizeStatusArray _ANSI_ARGS_((Element *elemPtr, int nPoints));
extern Point2D Blt_GetProjection _ANSI_ARGS_((int x, int y, int px, int py,
int qx, int qy));
extern int Blt_GetPenStyle _ANSI_ARGS_((Graph *graphPtr, char *name,
ObjectType type, PenStyle *stylePtr));
extern int Blt_NameToElement _ANSI_ARGS_((Graph *graphPtr, char *name,
Element **elemPtrPtr));
#define NumberOfPoints(e) MIN((e)->x.nValues, (e)->y.nValues)
#endif /* _BLT_GR_ELEM_H */
|