1 | /*
|
---|
2 | * bltGraph.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_GRAPH_H
|
---|
26 | #define _BLT_GRAPH_H
|
---|
27 |
|
---|
28 | #include "bltInt.h"
|
---|
29 | #include "bltHash.h"
|
---|
30 | #include "bltBind.h"
|
---|
31 | #include "bltChain.h"
|
---|
32 | #include "bltPs.h"
|
---|
33 | #include "bltTile.h"
|
---|
34 |
|
---|
35 | typedef struct GraphStruct Graph;
|
---|
36 | typedef struct ElementStruct Element;
|
---|
37 | typedef struct LegendStruct Legend;
|
---|
38 |
|
---|
39 | #include "bltGrAxis.h"
|
---|
40 | #include "bltGrLegd.h"
|
---|
41 |
|
---|
42 | #define MARKER_UNDER 1 /* Draw markers designated to lie underneath
|
---|
43 | * elements, grids, legend, etc. */
|
---|
44 | #define MARKER_ABOVE 0 /* Draw markers designated to rest above
|
---|
45 | * elements, grids, legend, etc. */
|
---|
46 |
|
---|
47 | #define PADX 2 /* Padding between labels/titles */
|
---|
48 | #define PADY 2 /* Padding between labels */
|
---|
49 |
|
---|
50 | #define MINIMUM_MARGIN 20 /* Minimum margin size */
|
---|
51 |
|
---|
52 |
|
---|
53 | #define BOUND(x, lo, hi) \
|
---|
54 | (((x) > (hi)) ? (hi) : ((x) < (lo)) ? (lo) : (x))
|
---|
55 |
|
---|
56 | /*
|
---|
57 | * -------------------------------------------------------------------
|
---|
58 | *
|
---|
59 | * Graph component structure definitions
|
---|
60 | *
|
---|
61 | * -------------------------------------------------------------------
|
---|
62 | */
|
---|
63 | #define PointInGraph(g,x,y) \
|
---|
64 | (((x) <= (g)->right) && ((x) >= (g)->left) && \
|
---|
65 | ((y) <= (g)->bottom) && ((y) >= (g)->top))
|
---|
66 |
|
---|
67 | /*
|
---|
68 | * -------------------------------------------------------------------
|
---|
69 | *
|
---|
70 | * ClassType --
|
---|
71 | *
|
---|
72 | * Enumerates the different types of graph elements this program
|
---|
73 | * produces. An element can be either a line or a bar.
|
---|
74 | *
|
---|
75 | * -------------------------------------------------------------------
|
---|
76 | */
|
---|
77 | typedef enum {
|
---|
78 | CLASS_UNKNOWN,
|
---|
79 | CLASS_LINE_ELEMENT,
|
---|
80 | CLASS_STRIP_ELEMENT,
|
---|
81 | CLASS_BAR_ELEMENT,
|
---|
82 | CLASS_BITMAP_MARKER,
|
---|
83 | CLASS_IMAGE_MARKER,
|
---|
84 | CLASS_LINE_MARKER,
|
---|
85 | CLASS_POLYGON_MARKER,
|
---|
86 | CLASS_TEXT_MARKER,
|
---|
87 | CLASS_WINDOW_MARKER
|
---|
88 |
|
---|
89 | } ClassType;
|
---|
90 |
|
---|
91 | /*
|
---|
92 | * Mask values used to selectively enable GRAPH or BARCHART entries in
|
---|
93 | * the various configuration specs.
|
---|
94 | */
|
---|
95 | #define GRAPH (TK_CONFIG_USER_BIT << 1)
|
---|
96 | #define STRIPCHART (TK_CONFIG_USER_BIT << 2)
|
---|
97 | #define BARCHART (TK_CONFIG_USER_BIT << 3)
|
---|
98 | #define LINE_GRAPHS (GRAPH | STRIPCHART)
|
---|
99 | #define ALL_GRAPHS (GRAPH | BARCHART | STRIPCHART)
|
---|
100 |
|
---|
101 | #define PEN_DELETE_PENDING (1<<0)
|
---|
102 | #define ACTIVE_PEN (TK_CONFIG_USER_BIT << 6)
|
---|
103 | #define NORMAL_PEN (TK_CONFIG_USER_BIT << 7)
|
---|
104 | #define ALL_PENS (NORMAL_PEN | ACTIVE_PEN)
|
---|
105 |
|
---|
106 | /*
|
---|
107 | * -------------------------------------------------------------------
|
---|
108 | *
|
---|
109 | * FreqInfo --
|
---|
110 | *
|
---|
111 | * -------------------------------------------------------------------
|
---|
112 | */
|
---|
113 | typedef struct {
|
---|
114 | int freq; /* Number of occurrences of x-coordinate */
|
---|
115 | Axis2D axes; /* Indicates which x and y axis are mapped to
|
---|
116 | * the x-value */
|
---|
117 | double sum; /* Sum of the ordinates of each duplicate
|
---|
118 | * abscissa */
|
---|
119 | int count;
|
---|
120 | double lastY;
|
---|
121 |
|
---|
122 | } FreqInfo;
|
---|
123 |
|
---|
124 | /*
|
---|
125 | * -------------------------------------------------------------------
|
---|
126 | *
|
---|
127 | * FreqKey --
|
---|
128 | *
|
---|
129 | *
|
---|
130 | * -------------------------------------------------------------------
|
---|
131 | */
|
---|
132 | typedef struct {
|
---|
133 | double value; /* Duplicated abscissa */
|
---|
134 | Axis2D axes; /* Axis mapping of element */
|
---|
135 | } FreqKey;
|
---|
136 |
|
---|
137 | /*
|
---|
138 | * BarModes --
|
---|
139 | *
|
---|
140 | * Bar elements are displayed according to their x-y coordinates.
|
---|
141 | * If two bars have the same abscissa (x-coordinate), the bar
|
---|
142 | * segments will be drawn according to one of the following
|
---|
143 | * modes:
|
---|
144 | */
|
---|
145 |
|
---|
146 | typedef enum BarModes {
|
---|
147 | MODE_INFRONT, /* Each successive segment is drawn in
|
---|
148 | * front of the previous. */
|
---|
149 | MODE_STACKED, /* Each successive segment is drawn
|
---|
150 | * stacked above the previous. */
|
---|
151 | MODE_ALIGNED, /* Each successive segment is drawn
|
---|
152 | * aligned to the previous from
|
---|
153 | * right-to-left. */
|
---|
154 | MODE_OVERLAP /* Like "aligned", each successive segment
|
---|
155 | * is drawn from right-to-left. In addition
|
---|
156 | * the segments will overlap each other
|
---|
157 | * by a small amount */
|
---|
158 | } BarMode;
|
---|
159 |
|
---|
160 | typedef struct PenStruct Pen;
|
---|
161 | typedef struct MarkerStruct Marker;
|
---|
162 |
|
---|
163 | typedef Pen *(PenCreateProc) _ANSI_ARGS_((void));
|
---|
164 | typedef int (PenConfigureProc) _ANSI_ARGS_((Graph *graphPtr, Pen *penPtr));
|
---|
165 | typedef void (PenDestroyProc) _ANSI_ARGS_((Graph *graphPtr, Pen *penPtr));
|
---|
166 |
|
---|
167 | struct PenStruct {
|
---|
168 | char *name; /* Pen style identifier. If NULL pen
|
---|
169 | * was statically allocated. */
|
---|
170 | Blt_Uid classUid; /* Type of pen */
|
---|
171 | char *typeId; /* String token identifying the type of pen */
|
---|
172 | unsigned int flags; /* Indicates if the pen element is active or
|
---|
173 | * normal */
|
---|
174 | int refCount; /* Reference count for elements using
|
---|
175 | * this pen. */
|
---|
176 | Blt_HashEntry *hashPtr;
|
---|
177 |
|
---|
178 | Tk_ConfigSpec *configSpecs; /* Configuration specifications */
|
---|
179 |
|
---|
180 | PenConfigureProc *configProc;
|
---|
181 | PenDestroyProc *destroyProc;
|
---|
182 |
|
---|
183 | };
|
---|
184 |
|
---|
185 | typedef enum {
|
---|
186 | PS_MONO_BACKGROUND,
|
---|
187 | PS_MONO_FOREGROUND
|
---|
188 | } MonoAttribute;
|
---|
189 |
|
---|
190 | /*
|
---|
191 | * PostScript --
|
---|
192 | *
|
---|
193 | * Structure contains information specific to the outputting of
|
---|
194 | * PostScript commands to print the graph.
|
---|
195 | *
|
---|
196 | */
|
---|
197 | typedef struct {
|
---|
198 | /* User configurable fields */
|
---|
199 |
|
---|
200 | int decorations; /* If non-zero, print graph with
|
---|
201 | * color background and 3D borders */
|
---|
202 |
|
---|
203 | int reqWidth, reqHeight; /* If greater than zero, represents the
|
---|
204 | * requested dimensions of the printed graph */
|
---|
205 | int reqPaperWidth;
|
---|
206 | int reqPaperHeight; /* Requested dimensions for the PostScript
|
---|
207 | * page. Can constrain the size of the graph
|
---|
208 | * if the graph (plus padding) is larger than
|
---|
209 | * the size of the page. */
|
---|
210 | Blt_Pad padX, padY; /* Requested padding on the exterior of the
|
---|
211 | * graph. This forms the bounding box for
|
---|
212 | * the page. */
|
---|
213 | PsColorMode colorMode; /* Selects the color mode for PostScript page
|
---|
214 | * (0=monochrome, 1=greyscale, 2=color) */
|
---|
215 | char *colorVarName; /* If non-NULL, is the name of a Tcl array
|
---|
216 | * variable containing X to PostScript color
|
---|
217 | * translations */
|
---|
218 | char *fontVarName; /* If non-NULL, is the name of a Tcl array
|
---|
219 | * variable containing X to PostScript font
|
---|
220 | * translations */
|
---|
221 | int landscape; /* If non-zero, orient the page 90 degrees */
|
---|
222 | int center; /* If non-zero, center the graph on the page */
|
---|
223 | int maxpect; /* If non-zero, indicates to scale the graph
|
---|
224 | * so that it fills the page (maintaining the
|
---|
225 | * aspect ratio of the graph) */
|
---|
226 | int addPreview; /* If non-zero, generate a preview image and
|
---|
227 | * add it to the PostScript output */
|
---|
228 | int footer; /* If non-zero, a footer with the title, date
|
---|
229 | * and user will be added to the PostScript
|
---|
230 | * output outside of the bounding box. */
|
---|
231 | int previewFormat; /* Format of EPS preview:
|
---|
232 | * PS_PREVIEW_WMF, PS_PREVIEW_EPSI, or
|
---|
233 | * PS_PREVIEW_TIFF. */
|
---|
234 |
|
---|
235 | /* Computed fields */
|
---|
236 |
|
---|
237 | int left, bottom; /* Bounding box of PostScript plot. */
|
---|
238 | int right, top;
|
---|
239 |
|
---|
240 | double pageScale; /* Scale of page. Set if "-maxpect" option
|
---|
241 | * is set, otherwise 1.0. */
|
---|
242 | } PostScript;
|
---|
243 |
|
---|
244 | /*
|
---|
245 | * -------------------------------------------------------------------
|
---|
246 | *
|
---|
247 | * Grid
|
---|
248 | *
|
---|
249 | * Contains attributes of describing how to draw grids (at major
|
---|
250 | * ticks) in the graph. Grids may be mapped to either/both x and
|
---|
251 | * y axis.
|
---|
252 | *
|
---|
253 | * -------------------------------------------------------------------
|
---|
254 | */
|
---|
255 | typedef struct {
|
---|
256 | GC gc; /* Graphics context for the grid. */
|
---|
257 | Axis2D axes;
|
---|
258 | int hidden; /* If non-zero, grid isn't displayed. */
|
---|
259 | int minorGrid; /* If non-zero, draw grid line for minor
|
---|
260 | * axis ticks too */
|
---|
261 | Blt_Dashes dashes; /* Dashstyle of the grid. This represents
|
---|
262 | * an array of alternatingly drawn pixel
|
---|
263 | * values. */
|
---|
264 | int lineWidth; /* Width of the grid lines */
|
---|
265 | XColor *colorPtr; /* Color of the grid lines */
|
---|
266 |
|
---|
267 | struct GridSegments {
|
---|
268 | Segment2D *segments; /* Array of line segments representing the
|
---|
269 | * x or y grid lines */
|
---|
270 | int nSegments; /* # of axis segments. */
|
---|
271 | } x, y;
|
---|
272 |
|
---|
273 | } Grid;
|
---|
274 |
|
---|
275 | /*
|
---|
276 | * -------------------------------------------------------------------
|
---|
277 | *
|
---|
278 | * Crosshairs
|
---|
279 | *
|
---|
280 | * Contains the line segments positions and graphics context used
|
---|
281 | * to simulate crosshairs (by XOR-ing) on the graph.
|
---|
282 | *
|
---|
283 | * -------------------------------------------------------------------
|
---|
284 | */
|
---|
285 | typedef struct CrosshairsStruct Crosshairs;
|
---|
286 |
|
---|
287 | typedef struct {
|
---|
288 | short int width, height; /* Extents of the margin */
|
---|
289 |
|
---|
290 | short int axesOffset;
|
---|
291 | short int axesTitleLength; /* Width of the widest title to be shown.
|
---|
292 | * Multiple titles are displayed in
|
---|
293 | * another margin. This is the minimum
|
---|
294 | * space requirement. */
|
---|
295 | unsigned int nAxes; /* Number of axes to be displayed */
|
---|
296 | Blt_Chain *axes; /* Extra axes associated with this margin */
|
---|
297 |
|
---|
298 | char *varName; /* If non-NULL, name of variable to be
|
---|
299 | * updated when the margin size changes */
|
---|
300 |
|
---|
301 | int reqSize; /* Requested size of margin */
|
---|
302 | int site; /* Indicates where margin is located:
|
---|
303 | * left/right/top/bottom. */
|
---|
304 | } Margin;
|
---|
305 |
|
---|
306 | #define MARGIN_NONE -1
|
---|
307 | #define MARGIN_BOTTOM 0
|
---|
308 | #define MARGIN_LEFT 1
|
---|
309 | #define MARGIN_TOP 2
|
---|
310 | #define MARGIN_RIGHT 3
|
---|
311 |
|
---|
312 | #define rightMargin margins[MARGIN_RIGHT]
|
---|
313 | #define leftMargin margins[MARGIN_LEFT]
|
---|
314 | #define topMargin margins[MARGIN_TOP]
|
---|
315 | #define bottomMargin margins[MARGIN_BOTTOM]
|
---|
316 |
|
---|
317 | /*
|
---|
318 | * -------------------------------------------------------------------
|
---|
319 | *
|
---|
320 | * Graph --
|
---|
321 | *
|
---|
322 | * Top level structure containing everything pertaining to
|
---|
323 | * the graph.
|
---|
324 | *
|
---|
325 | * -------------------------------------------------------------------
|
---|
326 | */
|
---|
327 | struct GraphStruct {
|
---|
328 | unsigned int flags; /* Flags; see below for definitions. */
|
---|
329 | Tcl_Interp *interp; /* Interpreter associated with graph */
|
---|
330 | Tk_Window tkwin; /* Window that embodies the graph. NULL
|
---|
331 | * means that the window has been
|
---|
332 | * destroyed but the data structures
|
---|
333 | * haven't yet been cleaned up. */
|
---|
334 | Display *display; /* Display containing widget; needed,
|
---|
335 | * among other things, to release
|
---|
336 | * resources after tkwin has already gone
|
---|
337 | * away. */
|
---|
338 | Tcl_Command cmdToken; /* Token for graph's widget command. */
|
---|
339 |
|
---|
340 | char *data; /* This value isn't used in C code.
|
---|
341 | * It may be used in Tcl bindings to
|
---|
342 | * associate extra data. */
|
---|
343 |
|
---|
344 | Tk_Cursor cursor;
|
---|
345 |
|
---|
346 | int inset; /* Sum of focus highlight and 3-D
|
---|
347 | * border. Indicates how far to
|
---|
348 | * offset the graph from outside
|
---|
349 | * edge of the window. */
|
---|
350 |
|
---|
351 | int borderWidth; /* Width of the exterior border */
|
---|
352 | int relief; /* Relief of the exterior border */
|
---|
353 | Tk_3DBorder border; /* 3-D border used to delineate the plot
|
---|
354 | * surface and outer edge of window */
|
---|
355 |
|
---|
356 | int highlightWidth; /* Width in pixels of highlight to draw
|
---|
357 | * around widget when it has the focus.
|
---|
358 | * <= 0 means don't draw a highlight. */
|
---|
359 | XColor *highlightBgColor; /* Color for drawing traversal highlight
|
---|
360 | * area when highlight is off. */
|
---|
361 | XColor *highlightColor; /* Color for drawing traversal highlight. */
|
---|
362 |
|
---|
363 | char *title;
|
---|
364 | short int titleX, titleY;
|
---|
365 | TextStyle titleTextStyle; /* Graph title */
|
---|
366 |
|
---|
367 | char *takeFocus;
|
---|
368 |
|
---|
369 | int reqWidth, reqHeight; /* Requested size of graph window */
|
---|
370 | int width, height; /* Size of graph window or PostScript
|
---|
371 | * page */
|
---|
372 |
|
---|
373 | Blt_HashTable penTable; /* Table of pens */
|
---|
374 |
|
---|
375 | struct Component {
|
---|
376 | Blt_HashTable table; /* Hash table of ids. */
|
---|
377 | Blt_Chain *displayList; /* Display list. */
|
---|
378 | Blt_HashTable tagTable; /* Table of bind tags. */
|
---|
379 | } elements, markers, axes;
|
---|
380 |
|
---|
381 | Blt_Uid classUid; /* Default element type */
|
---|
382 |
|
---|
383 | Blt_BindTable bindTable;
|
---|
384 | int nextMarkerId; /* Tracks next marker identifier available */
|
---|
385 |
|
---|
386 | Blt_Chain *axisChain[4]; /* Chain of axes for each of the
|
---|
387 | * margins. They're separate from the
|
---|
388 | * margin structures to make it easier
|
---|
389 | * to invert the X-Y axes by simply
|
---|
390 | * switching chain pointers.
|
---|
391 | */
|
---|
392 | Margin margins[4];
|
---|
393 |
|
---|
394 | PostScript *postscript; /* PostScript options: see bltGrPS.c */
|
---|
395 | Legend *legend; /* Legend information: see bltGrLegd.c */
|
---|
396 | Crosshairs *crosshairs; /* Crosshairs information: see bltGrHairs.c */
|
---|
397 | Grid *gridPtr; /* Grid attribute information */
|
---|
398 |
|
---|
399 | int halo; /* Maximum distance allowed between points
|
---|
400 | * when searching for a point */
|
---|
401 | int inverted; /* If non-zero, indicates the x and y axis
|
---|
402 | * positions should be inverted. */
|
---|
403 | Blt_Tile tile;
|
---|
404 | GC drawGC; /* Used for drawing on the margins. This
|
---|
405 | * includes the axis lines */
|
---|
406 | GC fillGC; /* Used to fill the background of the
|
---|
407 | * margins. The fill is governed by
|
---|
408 | * the background color or the tiled
|
---|
409 | * pixmap. */
|
---|
410 | int plotBorderWidth; /* Width of interior 3-D border. */
|
---|
411 | int plotRelief; /* 3-d effect: TK_RELIEF_RAISED etc. */
|
---|
412 | XColor *plotBg; /* Color of plotting surface */
|
---|
413 |
|
---|
414 | GC plotFillGC; /* Used to fill the plotting area with a
|
---|
415 | * solid background color. The fill color
|
---|
416 | * is stored in "plotBg". */
|
---|
417 |
|
---|
418 | /* If non-zero, force plot to conform to aspect ratio W/H */
|
---|
419 | double aspect;
|
---|
420 |
|
---|
421 | short int left, right; /* Coordinates of plot bbox */
|
---|
422 | short int top, bottom;
|
---|
423 |
|
---|
424 | Blt_Pad padX; /* Vertical padding for plotarea */
|
---|
425 | int vRange, vOffset; /* Vertical axis range and offset from the
|
---|
426 | * left side of the graph window. Used to
|
---|
427 | * transform coordinates to vertical
|
---|
428 | * axes. */
|
---|
429 | Blt_Pad padY; /* Horizontal padding for plotarea */
|
---|
430 | int hRange, hOffset; /* Horizontal axis range and offset from
|
---|
431 | * the top of the graph window. Used to
|
---|
432 | * transform horizontal axes */
|
---|
433 | double vScale, hScale;
|
---|
434 |
|
---|
435 | int doubleBuffer; /* If non-zero, draw the graph into a pixmap
|
---|
436 | * first to reduce flashing. */
|
---|
437 | int backingStore; /* If non-zero, cache elements by drawing
|
---|
438 | * them into a pixmap */
|
---|
439 | Pixmap backPixmap; /* Pixmap used to cache elements
|
---|
440 | * displayed. If *backingStore* is
|
---|
441 | * non-zero, each element is drawn
|
---|
442 | * into this pixmap before it is
|
---|
443 | * copied onto the screen. The pixmap
|
---|
444 | * then acts as a cache (only the
|
---|
445 | * pixmap is redisplayed if the none
|
---|
446 | * of elements have changed). This is
|
---|
447 | * done so that markers can be redrawn
|
---|
448 | * quickly over elements without
|
---|
449 | * redrawing each element. */
|
---|
450 | int backWidth, backHeight; /* Size of element backing store pixmap. */
|
---|
451 |
|
---|
452 | /*
|
---|
453 | * barchart specific information
|
---|
454 | */
|
---|
455 | double baseline; /* Baseline from bar chart. */
|
---|
456 | double barWidth; /* Default width of each bar in graph units.
|
---|
457 | * The default width is 1.0 units. */
|
---|
458 | BarMode mode; /* Mode describing how to display bars
|
---|
459 | * with the same x-coordinates. Mode can
|
---|
460 | * be "stack", "align", or "normal" */
|
---|
461 | FreqInfo *freqArr; /* Contains information about duplicate
|
---|
462 | * x-values in bar elements (malloc-ed).
|
---|
463 | * This information can also be accessed
|
---|
464 | * by the frequency hash table */
|
---|
465 | Blt_HashTable freqTable; /* */
|
---|
466 | int nStacks; /* Number of entries in frequency array.
|
---|
467 | * If zero, indicates nothing special needs
|
---|
468 | * to be done for "stack" or "align" modes */
|
---|
469 | char *dataCmd; /* New data callback? */
|
---|
470 |
|
---|
471 | };
|
---|
472 |
|
---|
473 | /*
|
---|
474 | * Bit flags definitions:
|
---|
475 | *
|
---|
476 | * All kinds of state information kept here. All these
|
---|
477 | * things happen when the window is available to draw into
|
---|
478 | * (DisplayGraph). Need the window width and height before
|
---|
479 | * we can calculate graph layout (i.e. the screen coordinates
|
---|
480 | * of the axes, elements, titles, etc). But we want to do this
|
---|
481 | * only when we have to, not every time the graph is redrawn.
|
---|
482 | *
|
---|
483 | * Same goes for maintaining a pixmap to double buffer graph
|
---|
484 | * elements. Need to mark when the pixmap needs to updated.
|
---|
485 | *
|
---|
486 | *
|
---|
487 | * MAP_ITEM Indicates that the element/marker/axis
|
---|
488 | * configuration has changed such that
|
---|
489 | * its layout of the item (i.e. its
|
---|
490 | * position in the graph window) needs
|
---|
491 | * to be recalculated.
|
---|
492 | *
|
---|
493 | * MAP_ALL Indicates that the layout of the axes and
|
---|
494 | * all elements and markers and the graph need
|
---|
495 | * to be recalculated. Otherwise, the layout
|
---|
496 | * of only those markers and elements that
|
---|
497 | * have changed will be reset.
|
---|
498 | *
|
---|
499 | * GET_AXIS_GEOMETRY Indicates that the size of the axes needs
|
---|
500 | * to be recalculated.
|
---|
501 | *
|
---|
502 | * RESET_AXES Flag to call to Blt_ResetAxes routine.
|
---|
503 | * This routine recalculates the scale offset
|
---|
504 | * (used for mapping coordinates) of each axis.
|
---|
505 | * If an axis limit has changed, then it sets
|
---|
506 | * flags to re-layout and redraw the entire
|
---|
507 | * graph. This needs to happend before the axis
|
---|
508 | * can compute transformations between graph and
|
---|
509 | * screen coordinates.
|
---|
510 | *
|
---|
511 | * LAYOUT_NEEDED
|
---|
512 | *
|
---|
513 | * REDRAW_BACKING_STORE If set, redraw all elements into the pixmap
|
---|
514 | * used for buffering elements.
|
---|
515 | *
|
---|
516 | * REDRAW_PENDING Non-zero means a DoWhenIdle handler has
|
---|
517 | * already been queued to redraw this window.
|
---|
518 | *
|
---|
519 | * DRAW_LEGEND Non-zero means redraw the legend. If this is
|
---|
520 | * the only DRAW_* flag, the legend display
|
---|
521 | * routine is called instead of the graph
|
---|
522 | * display routine.
|
---|
523 | *
|
---|
524 | * DRAW_MARGINS Indicates that the margins bordering
|
---|
525 | * the plotting area need to be redrawn.
|
---|
526 | * The possible reasons are:
|
---|
527 | *
|
---|
528 | * 1) an axis configuration changed
|
---|
529 | * 2) an axis limit changed
|
---|
530 | * 3) titles have changed
|
---|
531 | * 4) window was resized.
|
---|
532 | *
|
---|
533 | * GRAPH_FOCUS
|
---|
534 | */
|
---|
535 |
|
---|
536 | #define MAP_ITEM (1<<0) /* 0x0001 */
|
---|
537 | #define MAP_ALL (1<<1) /* 0x0002 */
|
---|
538 | #define GET_AXIS_GEOMETRY (1<<2) /* 0x0004 */
|
---|
539 | #define RESET_AXES (1<<3) /* 0x0008 */
|
---|
540 | #define LAYOUT_NEEDED (1<<4) /* 0x0010 */
|
---|
541 |
|
---|
542 | #define REDRAW_PENDING (1<<8) /* 0x0100 */
|
---|
543 | #define DRAW_LEGEND (1<<9) /* 0x0200 */
|
---|
544 | #define DRAW_MARGINS (1<<10)/* 0x0400 */
|
---|
545 | #define REDRAW_BACKING_STORE (1<<11)/* 0x0800 */
|
---|
546 |
|
---|
547 | #define GRAPH_FOCUS (1<<12)/* 0x1000 */
|
---|
548 | #define DATA_CHANGED (1<<13)/* 0x2000 */
|
---|
549 |
|
---|
550 | #define MAP_WORLD (MAP_ALL|RESET_AXES|GET_AXIS_GEOMETRY)
|
---|
551 | #define REDRAW_WORLD (DRAW_MARGINS | DRAW_LEGEND)
|
---|
552 | #define RESET_WORLD (REDRAW_WORLD | MAP_WORLD)
|
---|
553 |
|
---|
554 | /*
|
---|
555 | * ---------------------- Forward declarations ------------------------
|
---|
556 | */
|
---|
557 |
|
---|
558 | extern int Blt_CreatePostScript _ANSI_ARGS_((Graph *graphPtr));
|
---|
559 | extern int Blt_CreateCrosshairs _ANSI_ARGS_((Graph *graphPtr));
|
---|
560 | extern int Blt_CreateGrid _ANSI_ARGS_((Graph *graphPtr));
|
---|
561 | extern double Blt_InvHMap _ANSI_ARGS_((Graph *graphPtr, Axis *axisPtr,
|
---|
562 | double x));
|
---|
563 | extern double Blt_InvVMap _ANSI_ARGS_((Graph *graphPtr, Axis *axisPtr,
|
---|
564 | double x));
|
---|
565 | extern double Blt_HMap _ANSI_ARGS_((Graph *graphPtr, Axis *axisPtr, double x));
|
---|
566 | extern double Blt_VMap _ANSI_ARGS_((Graph *graphPtr, Axis *axisPtr, double y));
|
---|
567 | extern Point2D Blt_InvMap2D _ANSI_ARGS_((Graph *graphPtr, double x,
|
---|
568 | double y, Axis2D *pairPtr));
|
---|
569 | extern Point2D Blt_Map2D _ANSI_ARGS_((Graph *graphPtr, double x,
|
---|
570 | double y, Axis2D *pairPtr));
|
---|
571 | extern Graph *Blt_GetGraphFromWindowData _ANSI_ARGS_((Tk_Window tkwin));
|
---|
572 | extern void Blt_AdjustAxisPointers _ANSI_ARGS_((Graph *graphPtr));
|
---|
573 | extern int Blt_LineRectClip _ANSI_ARGS_((Extents2D *extsPtr, Point2D *p,
|
---|
574 | Point2D *q));
|
---|
575 | extern int Blt_PolyRectClip _ANSI_ARGS_((Extents2D *extsPtr, Point2D *inputPts,
|
---|
576 | int nInputPts, Point2D *outputPts));
|
---|
577 |
|
---|
578 | extern void Blt_ComputeStacks _ANSI_ARGS_((Graph *graphPtr));
|
---|
579 | extern void Blt_ConfigureCrosshairs _ANSI_ARGS_((Graph *graphPtr));
|
---|
580 | extern void Blt_DestroyAxes _ANSI_ARGS_((Graph *graphPtr));
|
---|
581 | extern void Blt_DestroyCrosshairs _ANSI_ARGS_((Graph *graphPtr));
|
---|
582 | extern void Blt_DestroyGrid _ANSI_ARGS_((Graph *graphPtr));
|
---|
583 | extern void Blt_DestroyElements _ANSI_ARGS_((Graph *graphPtr));
|
---|
584 | extern void Blt_DestroyMarkers _ANSI_ARGS_((Graph *graphPtr));
|
---|
585 | extern void Blt_DestroyPostScript _ANSI_ARGS_((Graph *graphPtr));
|
---|
586 | extern void Blt_DrawAxes _ANSI_ARGS_((Graph *graphPtr, Drawable drawable));
|
---|
587 | extern void Blt_DrawAxisLimits _ANSI_ARGS_((Graph *graphPtr,
|
---|
588 | Drawable drawable));
|
---|
589 | extern void Blt_DrawElements _ANSI_ARGS_((Graph *graphPtr, Drawable drawable));
|
---|
590 | extern void Blt_DrawActiveElements _ANSI_ARGS_((Graph *graphPtr,
|
---|
591 | Drawable drawable));
|
---|
592 | extern void Blt_DrawGraph _ANSI_ARGS_((Graph *graphPtr, Drawable drawable,
|
---|
593 | int backingStore));
|
---|
594 | extern void Blt_DrawGrid _ANSI_ARGS_((Graph *graphPtr, Drawable drawable));
|
---|
595 | extern void Blt_DrawMarkers _ANSI_ARGS_((Graph *graphPtr, Drawable drawable,
|
---|
596 | int under));
|
---|
597 | extern void Blt_Draw2DSegments _ANSI_ARGS_((Display *display,
|
---|
598 | Drawable drawable, GC gc, Segment2D *segments, int nSegments));
|
---|
599 | extern int Blt_GetCoordinate _ANSI_ARGS_((Tcl_Interp *interp,
|
---|
600 | char *expr, double *valuePtr));
|
---|
601 | extern void Blt_InitFreqTable _ANSI_ARGS_((Graph *graphPtr));
|
---|
602 | extern void Blt_LayoutGraph _ANSI_ARGS_((Graph *graphPtr));
|
---|
603 | extern void Blt_LayoutMargins _ANSI_ARGS_((Graph *graphPtr));
|
---|
604 | extern void Blt_EventuallyRedrawGraph _ANSI_ARGS_((Graph *graphPtr));
|
---|
605 | extern void Blt_ResetAxes _ANSI_ARGS_((Graph *graphPtr));
|
---|
606 | extern void Blt_ResetStacks _ANSI_ARGS_((Graph *graphPtr));
|
---|
607 | extern void Blt_GraphExtents _ANSI_ARGS_((Graph *graphPtr, Extents2D *extsPtr));
|
---|
608 | extern void Blt_DisableCrosshairs _ANSI_ARGS_((Graph *graphPtr));
|
---|
609 | extern void Blt_EnableCrosshairs _ANSI_ARGS_((Graph *graphPtr));
|
---|
610 | extern void Blt_MapAxes _ANSI_ARGS_((Graph *graphPtr));
|
---|
611 | extern void Blt_MapElements _ANSI_ARGS_((Graph *graphPtr));
|
---|
612 | extern void Blt_MapGraph _ANSI_ARGS_((Graph *graphPtr));
|
---|
613 | extern void Blt_MapMarkers _ANSI_ARGS_((Graph *graphPtr));
|
---|
614 | extern void Blt_MapGrid _ANSI_ARGS_((Graph *graphPtr));
|
---|
615 | extern void Blt_UpdateCrosshairs _ANSI_ARGS_((Graph *graphPtr));
|
---|
616 | extern void Blt_DestroyPens _ANSI_ARGS_((Graph *graphPtr));
|
---|
617 | extern int Blt_GetPen _ANSI_ARGS_((Graph *graphPtr, char *name,
|
---|
618 | Blt_Uid classUid, Pen **penPtrPtr));
|
---|
619 | extern Pen *Blt_BarPen _ANSI_ARGS_((char *penName));
|
---|
620 | extern Pen *Blt_LinePen _ANSI_ARGS_((char *penName));
|
---|
621 | extern Pen *Blt_CreatePen _ANSI_ARGS_((Graph *graphPtr, char *penName,
|
---|
622 | Blt_Uid classUid, int nOpts, char **options));
|
---|
623 | extern int Blt_InitLinePens _ANSI_ARGS_((Graph *graphPtr));
|
---|
624 | extern int Blt_InitBarPens _ANSI_ARGS_((Graph *graphPtr));
|
---|
625 | extern void Blt_FreePen _ANSI_ARGS_((Graph *graphPtr, Pen *penPtr));
|
---|
626 |
|
---|
627 | extern int Blt_VirtualAxisOp _ANSI_ARGS_((Graph *graphPtr, Tcl_Interp *interp,
|
---|
628 | int argc, char **argv));
|
---|
629 | extern int Blt_AxisOp _ANSI_ARGS_((Graph *graphPtr, int margin, int argc,
|
---|
630 | char **argv));
|
---|
631 | extern int Blt_ElementOp _ANSI_ARGS_((Graph *graphPtr, Tcl_Interp *interp,
|
---|
632 | int argc, char **argv, Blt_Uid classUid));
|
---|
633 | extern int Blt_GridOp _ANSI_ARGS_((Graph *graphPtr, Tcl_Interp *interp,
|
---|
634 | int argc, char **argv));
|
---|
635 | extern int Blt_CrosshairsOp _ANSI_ARGS_((Graph *graphPtr, Tcl_Interp *interp,
|
---|
636 | int argc, char **argv));
|
---|
637 | extern int Blt_MarkerOp _ANSI_ARGS_((Graph *graphPtr, Tcl_Interp *interp,
|
---|
638 | int argc, char **argv));
|
---|
639 | extern int Blt_PenOp _ANSI_ARGS_((Graph *graphPtr, Tcl_Interp *interp,
|
---|
640 | int argc, char **argv));
|
---|
641 | extern int Blt_PointInPolygon _ANSI_ARGS_((Point2D *samplePtr,
|
---|
642 | Point2D *screenPts, int nScreenPts));
|
---|
643 | extern int Blt_RegionInPolygon _ANSI_ARGS_((Extents2D *extsPtr, Point2D *points,
|
---|
644 | int nPoints, int enclosed));
|
---|
645 | extern int Blt_PointInSegments _ANSI_ARGS_((Point2D *samplePtr,
|
---|
646 | Segment2D *segments, int nSegments, double halo));
|
---|
647 | extern int Blt_PostScriptOp _ANSI_ARGS_((Graph *graphPtr, Tcl_Interp *interp,
|
---|
648 | int argc, char **argv));
|
---|
649 | extern int Blt_GraphUpdateNeeded _ANSI_ARGS_((Graph *graphPtr));
|
---|
650 | extern int Blt_DefaultAxes _ANSI_ARGS_((Graph *graphPtr));
|
---|
651 | extern Axis *Blt_GetFirstAxis _ANSI_ARGS_((Blt_Chain *chainPtr));
|
---|
652 | extern void Blt_UpdateAxisBackgrounds _ANSI_ARGS_((Graph *graphPtr));
|
---|
653 | extern void Blt_GetAxisSegments _ANSI_ARGS_((Graph *graphPtr, Axis *axisPtr,
|
---|
654 | Segment2D **segPtrPtr, int *nSegmentsPtr));
|
---|
655 | extern Marker *Blt_NearestMarker _ANSI_ARGS_((Graph *graphPtr, int x, int y,
|
---|
656 | int under));
|
---|
657 | extern Axis *Blt_NearestAxis _ANSI_ARGS_((Graph *graphPtr, int x, int y));
|
---|
658 |
|
---|
659 |
|
---|
660 | typedef ClientData (MakeTagProc) _ANSI_ARGS_((Graph *graphPtr, char *tagName));
|
---|
661 | extern MakeTagProc Blt_MakeElementTag;
|
---|
662 | extern MakeTagProc Blt_MakeMarkerTag;
|
---|
663 | extern MakeTagProc Blt_MakeAxisTag;
|
---|
664 |
|
---|
665 | extern Blt_BindTagProc Blt_GraphTags;
|
---|
666 | extern Blt_BindTagProc Blt_AxisTags;
|
---|
667 |
|
---|
668 | extern int Blt_GraphType _ANSI_ARGS_((Graph *graphPtr));
|
---|
669 |
|
---|
670 | /* ---------------------- Global declarations ------------------------ */
|
---|
671 |
|
---|
672 | extern Blt_Uid bltBarElementUid;
|
---|
673 | extern Blt_Uid bltLineElementUid;
|
---|
674 | extern Blt_Uid bltStripElementUid;
|
---|
675 | extern Blt_Uid bltLineMarkerUid;
|
---|
676 | extern Blt_Uid bltBitmapMarkerUid;
|
---|
677 | extern Blt_Uid bltImageMarkerUid;
|
---|
678 | extern Blt_Uid bltTextMarkerUid;
|
---|
679 | extern Blt_Uid bltPolygonMarkerUid;
|
---|
680 | extern Blt_Uid bltWindowMarkerUid;
|
---|
681 | extern Blt_Uid bltXAxisUid;
|
---|
682 | extern Blt_Uid bltYAxisUid;
|
---|
683 |
|
---|
684 | #endif /* _BLT_GRAPH_H */
|
---|