File: draw.h

package info (click to toggle)
yorick 1.5.08-1
  • links: PTS
  • area: main
  • in suites: woody
  • size: 7,508 kB
  • ctags: 7,937
  • sloc: ansic: 75,604; cpp: 1,282; lisp: 1,217; sh: 1,026; makefile: 616; fortran: 19
file content (258 lines) | stat: -rw-r--r-- 10,012 bytes parent folder | download
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
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
/*
 * DRAW.H
 *
 * $Id: draw.h,v 1.1 1993/08/27 17:08:43 munro Exp $
 *
 * Declare display list structures of GIST C interface
 *
 */
/*    Copyright (c) 1994.  The Regents of the University of California.
                    All rights reserved.  */

#ifndef DRAW_H
#define DRAW_H

#include "gist.h"

/* Virtual function table for display list objects */
typedef struct GdOpTable GdOpTable;
struct GdOpTable {
  int type;    /* element type-- E_LINES, ... E_SYSTEM */

  /* Kill is virtual destructor (constructors are GdLines, etc.)
     If all is non-0, then every element in this ring is killed */
  void (*Kill)(void *el);

  /* GetProps sets gistD and gistA from element, returns element type */
  int (*GetProps)(void *el);

  /* SetProps sets element properties from gistA, gistD
     If xyzChanged has CHANGE_XY or CHANGE_Z or both set, then
     log x and y arrays are freed or contours are recomputed or both.
     Returns 0 on success or 1 if memory error recomputing contours.  */
  int (*SetProps)(void *el, int xyzChanged);

  /* Draw generates appropriate drawing primitives for this element.
     Returns 0 if successful.  */
  int (*Draw)(void *el, int xIsLog, int yIsLog);

  /* Scan rescans the (x,y) extent of this element according to the
     flags (extreme values, log scaling) and limits, setting extreme
     limits as appropriate for this curve.  If the limits are restricted
     and if no points will be plotted, limits.xmin=limits.xmax or
     limits.ymin=limits.ymax on return.  The el->box is also set
     appropriately.  */
  int (*Scan)(void *el, int flags, GpBox *limits);

  /* Margin returns a box representing the amount of NDC space which
     should be left around the element's box to allow for finite line
     thickness, projecting text, and the like. */
  void (*Margin)(void *el, GpBox *margin);
};

/* Generic display list element */
typedef struct GdElement GdElement;
struct GdElement {
  GdOpTable *ops;  /* virtual function table */
  GdElement *next, *prev;  /* elements form doubly linked rings */
  GpBox box;       /* extreme values of coordinates for this object */
  int hidden;      /* hidden flag */
  char *legend;    /* descriptive text */
  int number;      /* drawing->nElements when this element added */
};

/* GdLines element */
typedef struct GeLines GeLines;
struct GeLines {
  GdElement el;
  GpBox linBox, logBox;         /* extreme values */
  int n;                        /* number of points */
  GpReal *x, *y, *xlog, *ylog;  /* (x,y) points */
  GpLineAttribs l;              /* line attributes */
  GaLineAttribs dl;             /* decorated line attributes */
  GpMarkerAttribs m;            /* marker attributes */
};

/* GdDisjoint element */
typedef struct GeDisjoint GeDisjoint;
struct GeDisjoint {
  GdElement el;
  GpBox linBox, logBox;         /* extreme values */
  int n;                        /* number of segments */
  GpReal *x, *y, *xlog, *ylog;  /* (px,py) points */
  GpReal *xq, *yq, *xqlog, *yqlog;  /* (qx,qy) points */
  GpLineAttribs l;              /* line attributes */
};

/* GdText element */
typedef struct GeText GeText;
struct GeText {
  GdElement el;
  GpReal x0, y0;                /* text position */
  char *text;                   /* text string */
  GpTextAttribs t;              /* text attributes */
};

/* GdCells element */
typedef struct GeCells GeCells;
struct GeCells {
  GdElement el;
  GpReal px, py, qx, qy;        /* colors[0][width-1] at (qx,py) */
  long width, height;           /* width and height of image */
  GpColor *colors;              /* image array */
  int rgb;
};

/* GdFill element */
typedef struct GePolys GePolys;
struct GePolys {
  GdElement el;
  GpBox linBox, logBox;         /* extreme values */
  GpReal *x, *y, *xlog, *ylog;  /* (px,py) points */
  long n, *pn;                  /* pn[n] list of polygon lengths */
  GpColor *colors;              /* n fill colors */
  GpLineAttribs e;              /* edge attributes */
  int rgb;
};

/* GdMesh element */
typedef struct GeMesh GeMesh;
struct GeMesh {
  GdElement el;
  GpBox linBox, logBox;         /* extreme values */
  int noCopy;                   /* also has bit for mesh.reg */
  GaQuadMesh mesh;              /* mesh coordinates */
  GpReal *xlog, *ylog;          /* 0 unless log axes */
  int region, boundary;         /* region number, boundary flag */
  GpLineAttribs l;              /* line attributes */
  int inhibit;                  /* +1 to inhibit j=const lines,
				   +2 to inhibit i=const lines */
};

/* GdFillMesh element */
typedef struct GeFill GeFill;
struct GeFill {
  GdElement el;
  GpBox linBox, logBox;         /* extreme values */
  int noCopy;                   /* also has bit for mesh.reg */
  GaQuadMesh mesh;              /* mesh coordinates */
  GpReal *xlog, *ylog;          /* 0 unless log axes */
  int region;                   /* this and above must match GeMesh */

  GpColor *colors;              /* color array */
  long nColumns;                /* row dimension of colors */
  GpLineAttribs e;              /* edge attributes */
  int rgb;
};

/* GdVectors element */
typedef struct GeVectors GeVectors;
struct GeVectors {
  GdElement el;
  GpBox linBox, logBox;         /* extreme values */
  int noCopy;                   /* also has bit for mesh.reg */
  GaQuadMesh mesh;              /* mesh coordinates */
  GpReal *xlog, *ylog;          /* 0 unless log axes */
  int region;                   /* this and above must match GeMesh */

  GpReal *u, *v;                /* iMax-by-jMax vector components (u,v) */
  GpReal scale;                 /* vectors plot as (dx,dy)=scale*(u,v) */
  GpLineAttribs l;              /* line attributes */
  GpFillAttribs f;              /* filled area attributes */
  GaVectAttribs vect;           /* vector attributes */
};

/* GdContours element */
typedef struct GeContours GeContours;
struct GeContours {
  GdElement el;
  GpBox linBox, logBox;         /* extreme values */
  int noCopy;                   /* also has bit for mesh.reg */
  GaQuadMesh mesh;              /* mesh coordinates */
  GpReal *xlog, *ylog;          /* 0 unless log axes */
  int region;                   /* this and above must match GeMesh */

  GpReal *z;                    /* iMax-by-jMax contour array */
  int nLevels;                  /* number of contour levels */
  GpReal *levels;               /* list of contour levels */
  GeLines **groups;             /* groups of contour curves at each level */
  GpLineAttribs l;              /* line attributes */
  GaLineAttribs dl;             /* decorated line attributes */
  GpMarkerAttribs m;            /* marker attributes */
};

/* Coordinate system-- a GpTransform with a tick style */
typedef struct GeSystem GeSystem;
struct GeSystem {
  GdElement el;
  GaTickStyle ticks;      /* tick style */
  GpTransform trans;      /* viewport and window */
  int flags;              /* for computing the limits (see GdProperties) */
  int rescan;             /* set if must be rescanned before redraw */
  int unscanned;          /* element number of 1st unscanned element */
  GdElement *elements;    /* elements in this coordinate system */
  GpBox savedWindow;      /* saved window limits for GdSaveLimits */
  int savedFlags;         /* saved flags for GdSaveLimits */
  GaAltTicks *xtick, *ytick;    /* alternative tick and label generators */
  GaAltLabel *xlabel, *ylabel;
};

typedef struct GeLegendBox GeLegendBox;
struct GeLegendBox {
  GpReal x, y;              /* NDC location of this legend box */
  GpReal dx, dy;            /* if non-zero, offset to 2nd column */
  GpTextAttribs textStyle;  /* font, size, etc. of these legends */
  int nchars, nlines;       /* max number of characters per line, lines */
  int nwrap;                /* max number of lines to wrap long legends */
};

/* Drawing-- the complete display list */
struct Drauing {
  Drauing *next;          /* drawings kept in a list */
  int cleared;            /* next element added will delete everything */
  int nSystems;           /* total number of systems (now) in drawing */
  int nElements;          /* total number of elements (ever) in drawing */
  GeSystem *systems;      /* coordinate systems */
  GdElement *elements;    /* elements not belonging to any system */
  int damaged;            /* set if damage box meaningful */
  GpBox damage;           /* region damaged by GdEdit, etc. */
  int landscape;          /* non-0 for landscape, 0 for portrait */
  GeLegendBox legends[2]; /* 0 is normal legend box, 1 is contours */
};

/* The list of GIST drawings */
extern Drauing *gistDrawList;

/* The following functions are intended to assist in writing the
   constructors for new types of Drauing Elements */

/* generic function for adding elements to current system--
   note that you must reset el->ops by hand, since only the predefined
   types are treated properly */
extern void GeAddElement(int type, GdElement *element);

/* generic function to mark element as unscanned if in a coordinate
   system, else set its box */
extern void GeMarkForScan(GdElement *el, GpBox *linBox);

/* generic function to get the current mesh, returning a GeMeshXY*,
   and optionally not copying the gistA.mesh arrays.  The return
   value is iMax*jMax (0 on failure) */
extern long GeGetMesh(int noCopy, GaQuadMesh *meshin, int region,
		      void *vMeshEl);

/* Updates the system limits if necessary -- do not use lightly.  */
extern int GdScan(GeSystem *system);

/* Defined in engine.c.  These routines communicate state information
   from the drawing to the engine.  They are not intended for external
   use.  */
extern int GdBeginDr(Drauing *drawing, GpBox *damage, int landscape);
   /* GdBeginSy returns 1 bit to draw elements, 2 bit to draw ticks */
extern int GdBeginSy(GpBox *tickOut, GpBox *tickIn,
		     GpBox *viewport, int number, int sysIndex);
   /* GdBeginEl returns 1 if elements should be drawn, else 0 */
extern int GdBeginEl(GpBox *box, int number);
extern void GdEndDr(void);

#endif