source: trunk/kitgen/8.x/blt/generic/bltGrElem.h@ 176

Last change on this file since 176 was 175, checked in by demin, 12 years ago

initial commit

File size: 9.4 KB
RevLine 
[175]1/*
2 * bltGrElem.h --
3 *
4 * Copyright 1991-1998 Lucent Technologies, Inc.
5 *
6 * Permission to use, copy, modify, and distribute this software and
7 * its documentation for any purpose and without fee is hereby
8 * granted, provided that the above copyright notice appear in all
9 * copies and that both that the copyright notice and warranty
10 * disclaimer appear in supporting documentation, and that the names
11 * of Lucent Technologies any of their entities not be used in
12 * advertising or publicity pertaining to distribution of the software
13 * without specific, written prior permission.
14 *
15 * Lucent Technologies disclaims all warranties with regard to this
16 * software, including all implied warranties of merchantability and
17 * fitness. In no event shall Lucent Technologies be liable for any
18 * special, indirect or consequential damages or any damages
19 * whatsoever resulting from loss of use, data or profits, whether in
20 * an action of contract, negligence or other tortuous action, arising
21 * out of or in connection with the use or performance of this
22 * software.
23 */
24
25#ifndef _BLT_GR_ELEM_H
26#define _BLT_GR_ELEM_H
27
28#define SEARCH_X 0
29#define SEARCH_Y 1
30#define SEARCH_BOTH 2
31
32#define SHOW_NONE 0
33#define SHOW_X 1
34#define SHOW_Y 2
35#define SHOW_BOTH 3
36
37#define SEARCH_POINTS 0 /* Search for closest data point. */
38#define SEARCH_TRACES 1 /* Search for closest point on trace.
39 * Interpolate the connecting line segments
40 * if necessary. */
41#define SEARCH_AUTO 2 /* Automatically determine whether to search
42 * for data points or traces. Look for
43 * traces if the linewidth is > 0 and if
44 * there is more than one data point. */
45
46#define ELEM_ACTIVE (1<<8) /* Non-zero indicates that the element
47 * should be drawn in its active
48 * foreground and background
49 * colors. */
50#define ACTIVE_PENDING (1<<7)
51
52#define LABEL_ACTIVE (1<<9) /* Non-zero indicates that the
53 * element's entry in the legend
54 * should be drawn in its active
55 * foreground and background
56 * colors. */
57#define SCALE_SYMBOL (1<<10)
58
59#define NumberOfPoints(e) MIN((e)->x.nValues, (e)->y.nValues)
60
61/*
62 * -------------------------------------------------------------------
63 *
64 * Weight --
65 *
66 * Designates a range of values by a minimum and maximum limit.
67 *
68 * -------------------------------------------------------------------
69 */
70typedef struct {
71 double min, max, range;
72} Weight;
73
74#define SetRange(l) \
75 ((l).range = ((l).max > (l).min) ? ((l).max - (l).min) : DBL_EPSILON)
76#define SetScale(l) \
77 ((l).scale = 1.0 / (l).range)
78#define SetWeight(l, lo, hi) \
79 ((l).min = (lo), (l).max = (hi), SetRange(l))
80
81/*
82 * An element has one or more vectors plus several attributes, such as
83 * line style, thickness, color, and symbol type. It has an
84 * identifier which distinguishes it among the list of all elements.
85 */
86typedef struct {
87 Weight weight; /* Weight range where this pen is valid. */
88
89 Pen *penPtr; /* Pen to use. */
90
91 Segment2D *xErrorBars; /* Point to start of this pen's X-error bar
92 * segments in the element's array. */
93
94 Segment2D *yErrorBars; /* Point to start of this pen's Y-error bar
95 * segments in the element's array. */
96
97 int xErrorBarCnt; /* # of error bars for this pen. */
98
99 int yErrorBarCnt; /* # of error bars for this pen. */
100
101 int errorBarCapWidth; /* Length of the cap ends on each
102 * error bar. */
103
104 int symbolSize; /* Size of the pen's symbol scaled to
105 * the current graph size. */
106} PenStyle;
107
108
109typedef struct {
110 XColor *color; /* Color of error bar */
111 int lineWidth; /* Width of the error bar segments. */
112 GC gc;
113 int show; /* Flags for errorbars: none, x, y, or both */
114
115} ErrorBarAttributes;
116
117typedef struct {
118 int halo; /* Maximal distance a candidate point
119 * can be from the sample window
120 * coordinate */
121
122 int mode; /* Indicates whether to find the closest
123 * data point or the closest point on the
124 * trace by interpolating the line segments.
125 * Can also be SEARCH_AUTO, indicating to
126 * choose how to search.*/
127
128 int x, y; /* Screen coordinates of test point */
129
130 int along; /* Indicates to let search run along a
131 * particular axis: x, y, or both. */
132
133 /* Output */
134 Element *elemPtr; /* Name of the closest element */
135
136 Point2D point; /* Graph coordinates of closest point */
137
138 int index; /* Index of closest data point */
139
140 double dist; /* Distance in screen coordinates */
141
142} ClosestSearch;
143
144typedef void (ElementDrawProc) _ANSI_ARGS_((Graph *graphPtr, Drawable drawable,
145 Element *elemPtr));
146typedef void (ElementToPostScriptProc) _ANSI_ARGS_((Graph *graphPtr,
147 PsToken psToken, Element *elemPtr));
148typedef void (ElementDestroyProc) _ANSI_ARGS_((Graph *graphPtr,
149 Element *elemPtr));
150typedef int (ElementConfigProc) _ANSI_ARGS_((Graph *graphPtr,
151 Element *elemPtr));
152typedef void (ElementMapProc) _ANSI_ARGS_((Graph *graphPtr,
153 Element *elemPtr));
154typedef void (ElementExtentsProc) _ANSI_ARGS_((Element *elemPtr,
155 Extents2D *extsPtr));
156typedef void (ElementClosestProc) _ANSI_ARGS_((Graph *graphPtr,
157 Element *elemPtr, ClosestSearch *searchPtr));
158typedef void (ElementDrawSymbolProc) _ANSI_ARGS_((Graph *graphPtr,
159 Drawable drawable, Element *elemPtr, int x, int y, int symbolSize));
160typedef void (ElementSymbolToPostScriptProc) _ANSI_ARGS_((Graph *graphPtr,
161 PsToken psToken, Element *elemPtr, double x, double y, int symSize));
162
163typedef struct {
164 ElementClosestProc *closestProc;
165 ElementConfigProc *configProc;
166 ElementDestroyProc *destroyProc;
167 ElementDrawProc *drawActiveProc;
168 ElementDrawProc *drawNormalProc;
169 ElementDrawSymbolProc *drawSymbolProc;
170 ElementExtentsProc *extentsProc;
171 ElementToPostScriptProc *printActiveProc;
172 ElementToPostScriptProc *printNormalProc;
173 ElementSymbolToPostScriptProc *printSymbolProc;
174 ElementMapProc *mapProc;
175} ElementProcs;
176
177/*
178 * The data structure below contains information pertaining to a line
179 * vector. It consists of an array of floating point data values and
180 * for convenience, the number and minimum/maximum values.
181 */
182
183typedef struct {
184 Blt_Vector *vecPtr;
185
186 double *valueArr;
187
188 int nValues;
189
190 int arraySize;
191
192 double min, max;
193
194 Blt_VectorId clientId; /* If non-NULL, a client token identifying the
195 * external vector. */
196
197 Element *elemPtr; /* Element associated with vector. */
198
199} ElemVector;
200
201
202struct ElementStruct {
203 char *name; /* Identifier to refer the element.
204 * Used in the "insert", "delete", or
205 * "show", commands. */
206
207 Blt_Uid classUid; /* Type of element */
208
209 Graph *graphPtr; /* Graph widget of element*/
210
211 unsigned int flags; /* Indicates if the entire element is
212 * active, or if coordinates need to
213 * be calculated */
214
215 char **tags;
216
217 int hidden; /* If non-zero, don't display the element. */
218
219 Blt_HashEntry *hashPtr;
220
221 char *label; /* Label displayed in legend */
222
223 int labelRelief; /* Relief of label in legend. */
224
225 Axis2D axes; /* X-axis and Y-axis mapping the element */
226
227 ElemVector x, y, w; /* Contains array of floating point
228 * graph coordinate values. Also holds
229 * min/max and the number of
230 * coordinates */
231
232 ElemVector xError; /* Relative/symmetric X error values. */
233 ElemVector yError; /* Relative/symmetric Y error values. */
234 ElemVector xHigh, xLow; /* Absolute/asymmetric X-coordinate high/low
235 error values. */
236 ElemVector yHigh, yLow; /* Absolute/asymmetric Y-coordinate high/low
237 error values. */
238
239 int *activeIndices; /* Array of indices (malloc-ed) which
240 * indicate which data points are
241 * active (drawn with "active"
242 * colors). */
243
244 int nActiveIndices; /* Number of active data points.
245 * Special case: if nActiveIndices < 0
246 * and the active bit is set in
247 * "flags", then all data points are
248 * drawn active. */
249
250 ElementProcs *procsPtr;
251
252 Tk_ConfigSpec *specsPtr; /* Configuration specifications. */
253
254 Segment2D *xErrorBars; /* Point to start of this pen's X-error bar
255 * segments in the element's array. */
256 Segment2D *yErrorBars; /* Point to start of this pen's Y-error bar
257 * segments in the element's array. */
258 int xErrorBarCnt; /* # of error bars for this pen. */
259 int yErrorBarCnt; /* # of error bars for this pen. */
260
261 int *xErrorToData; /* Maps error bar segments back to the data
262 * point. */
263 int *yErrorToData; /* Maps error bar segments back to the data
264 * point. */
265
266 int errorBarCapWidth; /* Length of cap on error bars */
267
268 Pen *activePenPtr; /* Standard Pens */
269 Pen *normalPenPtr;
270
271 Blt_Chain *palette; /* Palette of pens. */
272
273 /* Symbol scaling */
274 int scaleSymbols; /* If non-zero, the symbols will scale
275 * in size as the graph is zoomed
276 * in/out. */
277
278 double xRange, yRange; /* Initial X-axis and Y-axis ranges:
279 * used to scale the size of element's
280 * symbol. */
281 int state;
282};
283
284
285extern double Blt_FindElemVectorMinimum _ANSI_ARGS_((ElemVector *vecPtr,
286 double minLimit));
287extern void Blt_ResizeStatusArray _ANSI_ARGS_((Element *elemPtr, int nPoints));
288extern int Blt_GetPenStyle _ANSI_ARGS_((Graph *graphPtr, char *name,
289 Blt_Uid classUid, PenStyle *stylePtr));
290extern void Blt_FreePalette _ANSI_ARGS_((Graph *graphPtr, Blt_Chain *palette));
291extern PenStyle **Blt_StyleMap _ANSI_ARGS_((Element *elemPtr));
292extern void Blt_MapErrorBars _ANSI_ARGS_((Graph *graphPtr, Element *elemPtr,
293 PenStyle **dataToStyle));
294
295#endif /* _BLT_GR_ELEM_H */
Note: See TracBrowser for help on using the repository browser.