2 * FIG : Facility for Interactive Generation of figures
3 * Copyright (c) 1985 by Supoj Sutanthavibul
4 * Parts Copyright (c) 1994 by Brian V. Smith
5 * Parts Copyright (c) 1991 by Paul King
7 * The X Consortium, and any party obtaining a copy of these files from
8 * the X Consortium, directly or indirectly, is granted, free of charge, a
9 * full and unrestricted irrevocable, world-wide, paid up, royalty-free,
10 * nonexclusive right and license to deal in this software and
11 * documentation files (the "Software"), including without limitation the
12 * rights to use, copy, modify, merge, publish, distribute, sublicense,
13 * and/or sell copies of the Software, and to permit persons who receive
14 * copies from any such party to do so, with the only requirement being
15 * that this copyright notice remain intact. This license includes without
16 * limitation a license to do the foregoing actions under any patents of
17 * the party supplying this software to the X Consortium.
20 /* This file has been modified for use with Gnuplot 3.6 by
24 /* DEFAULT is used for many things - font, color etc */
44 /** VERY IMPORTANT: The f_line, f_spline and f_arc objects all must have the
45 components up to and including the arrows in the same order.
46 This is for the get/put_generic_arrows() in e_edit.c.
49 typedef struct f_point {
54 typedef struct f_pos {
59 #define DEF_ARROW_WID (4 * ZOOM_FACTOR)
60 #define DEF_ARROW_HT (8 * ZOOM_FACTOR)
62 typedef struct f_arrow {
71 typedef struct f_ellipse {
75 #define T_ELLIPSE_BY_RAD 1
76 #define T_ELLIPSE_BY_DIA 2
77 #define T_CIRCLE_BY_RAD 3
78 #define T_CIRCLE_BY_DIA 4
91 struct f_pos radiuses;
94 struct f_ellipse *next;
98 /* SEE NOTE AT TOP BEFORE CHANGING ANYTHING IN THE f_arc STRUCTURE */
100 typedef struct f_arc {
104 /* note: these arc types are the internal values */
105 /* in the file, they are open=1, wedge=2 */
107 #define T_PIE_WEDGE_ARC 1
115 struct f_arrow *for_arrow;
116 struct f_arrow *back_arrow;
117 /* THE PRECEDING VARS MUST BE IN THE SAME ORDER IN f_arc, f_line and f_spline */
124 struct f_pos point[3];
129 #define CLOSED_PATH 0
131 #define DEF_BOXRADIUS 7
132 #define DEF_DASHLENGTH 4
135 typedef struct f_pic {
142 #define T_PIC_BITMAP 2
143 #define T_PIC_PIXMAP 3
145 #define FileInvalid -2
147 unsigned char *bitmap;
148 int numcols; /* number of colors in cmap */
150 int size_x, size_y; /* fig units */
151 struct f_pos bit_size; /* pixels */
152 Color color; /* only used for XBM */
153 int pix_rotation, pix_width, pix_height, pix_flipped;
157 extern char EMPTY_PIC[];
159 /* SEE NOTE AT TOP BEFORE CHANGING ANYTHING IN THE f_line STRUCTURE */
161 typedef struct f_line {
177 struct f_arrow *for_arrow;
178 struct f_arrow *back_arrow;
179 /* THE PRECEDING VARS MUST BE IN THE SAME ORDER IN f_arc, f_line and f_spline */
180 int cap_style; /* line cap style - Butt, Round, Bevel */
183 #define CAP_PROJECT 2
184 struct f_point *points; /* this must immediately follow cap_style */
185 int join_style; /* join style - Miter, Round, Bevel */
190 int radius; /* corner radius for T_ARC_BOX */
196 typedef struct f_text {
200 #define T_LEFT_JUSTIFIED 0
201 #define T_CENTER_JUSTIFIED 1
202 #define T_RIGHT_JUSTIFIED 2
204 /* PIX_FONT fontstruct; */
205 int size; /* point size */
208 float angle; /* in radians */
212 #define SPECIAL_TEXT 2
213 #define PSFONT_TEXT 4
214 #define HIDDEN_TEXT 8
216 int ascent; /* Fig units */
217 int length; /* Fig units */
218 int descent; /* from XTextExtents(), not in file */
227 #define MAXFONT(T) (psfont_text(T) ? NUM_FONTS : NUM_LATEX_FONTS)
229 #define rigid_text(t) \
230 (t->flags == DEFAULT \
231 || (t->flags & RIGID_TEXT))
233 #define special_text(t) \
234 ((t->flags != DEFAULT \
235 && (t->flags & SPECIAL_TEXT)))
237 #define psfont_text(t) \
238 (t->flags != DEFAULT \
239 && (t->flags & PSFONT_TEXT))
241 #define hidden_text(t) \
242 (t->flags != DEFAULT \
243 && (t->flags & HIDDEN_TEXT))
245 #define text_length(t) \
246 (hidden_text(t) ? hidden_text_length : t->length)
248 #define using_ps (cur_textflags & PSFONT_TEXT)
250 typedef struct f_control {
251 float lx, ly, rx, ry;
252 struct f_control *next;
256 /* SEE NOTE AT TOP BEFORE CHANGING ANYTHING IN THE f_spline STRUCTURE */
258 #define int_spline(s) (s->type & 0x2)
259 #define normal_spline(s) (!(s->type & 0x2))
260 #define closed_spline(s) (s->type & 0x1)
261 #define open_spline(s) (!(s->type & 0x1))
263 typedef struct f_spline {
267 #define T_OPEN_NORMAL 0
268 #define T_CLOSED_NORMAL 1
269 #define T_OPEN_INTERP 2
270 #define T_CLOSED_INTERP 3
278 struct f_arrow *for_arrow;
279 struct f_arrow *back_arrow;
280 /* THE PRECEDING VARS MUST BE IN THE SAME ORDER IN f_arc, f_line and f_spline */
283 * For T_OPEN_NORMAL and T_CLOSED_NORMAL points are control points while
284 * they are knots for T_OPEN_INTERP and T_CLOSED_INTERP whose control
285 * points are stored in controls.
287 struct f_point *points; /* this must immediately follow cap_style */
289 struct f_control *controls;
290 struct f_spline *next;
294 typedef struct f_compound {
297 struct f_pos nwcorner;
298 struct f_pos secorner;
299 struct f_line *lines;
300 struct f_ellipse *ellipses;
301 struct f_spline *splines;
302 struct f_text *texts;
304 struct f_compound *compounds;
305 struct f_compound *next;
309 typedef struct f_linkinfo {
311 struct f_point *endpt;
312 struct f_point *prevpt;
314 struct f_linkinfo *next;
318 /* separate the "type" and the "style" from the cur_arrowtype */
319 #define ARROW_TYPE(x) ((x)==0? 0 : ((x)+1)/2)
320 #define ARROW_STYLE(x) ((x)==0? 0 : ((x)+1)%2)
322 #define ARROW_SIZE sizeof(struct f_arrow)
323 #define POINT_SIZE sizeof(struct f_point)
324 #define CONTROL_SIZE sizeof(struct f_control)
325 #define ELLOBJ_SIZE sizeof(struct f_ellipse)
326 #define ARCOBJ_SIZE sizeof(struct f_arc)
327 #define LINOBJ_SIZE sizeof(struct f_line)
328 #define TEXOBJ_SIZE sizeof(struct f_text)
329 #define SPLOBJ_SIZE sizeof(struct f_spline)
330 #define COMOBJ_SIZE sizeof(struct f_compound)
331 #define PIC_SIZE sizeof(struct f_pic)
332 #define LINKINFO_SIZE sizeof(struct f_linkinfo)
334 /********************** object codes **********************/
336 #define O_COLOR_DEF 0
340 /* HBB 990329: quick hack: 'O_TEXT' is in use by <fcntl.h> header
341 * on DOS/Windows platforms. Renamed to OBJ_TEXT */
345 #define O_END_COMPOUND -O_COMPOUND
346 #define O_ALL_OBJECT 99
348 /********************* object masks for update ************************/
351 #define M_POLYLINE_POLYGON 0x001
352 #define M_POLYLINE_LINE 0x002
353 #define M_POLYLINE_BOX 0x004 /* includes ARCBOX */
354 #define M_SPLINE_O_NORMAL 0x008
355 #define M_SPLINE_C_NORMAL 0x010
356 #define M_SPLINE_O_INTERP 0x020
357 #define M_SPLINE_C_INTERP 0x040
358 #define M_TEXT_NORMAL 0x080
359 #define M_TEXT_HIDDEN 0x100
361 #define M_ELLIPSE 0x400
362 #define M_COMPOUND 0x800
364 #define M_TEXT (M_TEXT_HIDDEN | M_TEXT_NORMAL)
365 #define M_SPLINE_O (M_SPLINE_O_NORMAL | M_SPLINE_O_INTERP)
366 #define M_SPLINE_C (M_SPLINE_C_NORMAL | M_SPLINE_C_INTERP)
367 #define M_SPLINE_NORMAL (M_SPLINE_O_NORMAL | M_SPLINE_C_NORMAL)
368 #define M_SPLINE_INTERP (M_SPLINE_O_INTERP | M_SPLINE_C_INTERP)
369 #define M_SPLINE (M_SPLINE_NORMAL | M_SPLINE_INTERP)
370 #define M_POLYLINE (M_POLYLINE_LINE | M_POLYLINE_POLYGON | M_POLYLINE_BOX)
371 #define M_VARPTS_OBJECT (M_POLYLINE_LINE | M_POLYLINE_POLYGON | M_SPLINE)
372 #define M_OPEN_OBJECT (M_POLYLINE_LINE | M_SPLINE_O | M_ARC)
373 #define M_ROTATE_ANGLE (M_VARPTS_OBJECT | M_ARC | M_TEXT | M_COMPOUND | M_ELLIPSE)
374 #define M_ELLTEXTANGLE (M_ELLIPSE | M_TEXT)
375 #define M_OBJECT (M_ELLIPSE | M_POLYLINE | M_SPLINE | M_TEXT | M_ARC)
376 #define M_NO_TEXT (M_ELLIPSE | M_POLYLINE | M_SPLINE | M_COMPOUND | M_ARC)
377 #define M_ALL (M_OBJECT | M_COMPOUND)
379 /************************ Objects **********************/
381 extern F_compound objects;
383 /************ global working pointers ************/
385 extern F_line *cur_l, *new_l, *old_l;
386 extern F_arc *cur_a, *new_a, *old_a;
387 extern F_ellipse *cur_e, *new_e, *old_e;
388 extern F_text *cur_t, *new_t, *old_t;
389 extern F_spline *cur_s, *new_s, *old_s;
390 extern F_compound *cur_c, *new_c, *old_c;
391 extern F_point *first_point, *cur_point;
392 extern F_linkinfo *cur_links;
394 /*************** object attribute settings ***********/
397 extern int cur_linewidth;
398 extern int cur_linestyle;
399 extern int cur_joinstyle;
400 extern int cur_capstyle;
401 extern float cur_dashlength;
402 extern float cur_dotgap;
403 extern float cur_styleval;
404 extern Color cur_fillcolor, cur_pencolor;
405 extern int cur_fillstyle, cur_penstyle;
406 extern int cur_boxradius;
407 extern int cur_arrowmode;
408 extern int cur_arrowtype;
409 extern int cur_arctype;
412 extern int cur_fontsize; /* font size */
413 extern int cur_latex_font;
414 extern int cur_ps_font;
415 extern int cur_textjust;
416 extern int cur_textflags;
419 extern float cur_elltextangle;