2
* FIG : Facility for Interactive Generation of figures
3
* Copyright (c) 1985-1988 by Supoj Sutanthavibul
4
* Parts Copyright (c) 1989-2000 by Brian V. Smith
5
* Parts Copyright (c) 1991 by Paul King
7
* Any party obtaining a copy of these files is granted, free of charge, a
8
* full and unrestricted irrevocable, world-wide, paid up, royalty-free,
9
* nonexclusive right and license to deal in this software and
10
* documentation files (the "Software"), including without limitation the
11
* rights to use, copy, modify, merge, publish, distribute, sublicense,
12
* and/or sell copies of the Software, and to permit persons who receive
13
* copies from any such party to do so, with the only requirement being
14
* that this copyright notice remain intact.
21
/* values to signify color used for transparent GIF color */
23
#define TRANSP_BACKGROUND -3 /* use background of figure as transp color */
24
#define TRANSP_NONE -2 /* no transp color */
25
#define COLOR_NONE -2 /* no background color (exporting) */
27
/* DEFAULT is used for many things - font, color etc */
34
#define DASH_DOT_LINE 3
35
#define DASH_2_DOTS_LINE 4
36
#define DASH_3_DOTS_LINE 5
38
#define RUBBER_LINE 11
51
/** VERY IMPORTANT: The f_line, f_spline and f_arc objects all must have the
52
components up to and including the arrows in the same order.
53
This is for the get/put_generic_arrows() in e_edit.c.
54
In addition, the f_line and f_spline objects must have the
55
components up to and including the f_points in the same order.
58
typedef struct f_point {
64
typedef struct f_pos {
69
#define DEF_ARROW_WID 4
70
#define DEF_ARROW_HT 8
72
typedef struct f_arrow {
83
typedef struct f_ellipse {
87
#define T_ELLIPSE_BY_RAD 1
88
#define T_ELLIPSE_BY_DIA 2
89
#define T_CIRCLE_BY_RAD 3
90
#define T_CIRCLE_BY_DIA 4
103
struct f_pos radiuses;
107
struct f_ellipse *next;
111
/* SEE NOTE AT TOP BEFORE CHANGING ANYTHING IN THE f_arc STRUCTURE */
115
typedef struct f_arc {
119
/* note: these arc types are the internal values */
120
/* in the file, they are open=1, wedge=2 */
122
#define T_PIE_WEDGE_ARC 1
131
struct f_arrow *for_arrow;
132
struct f_arrow *back_arrow;
136
#define CAP_PROJECT 2
138
/* THE PRECEDING VARS MUST BE IN THE SAME ORDER IN f_arc, f_line and f_spline */
144
struct f_pos point[3];
150
#define CLOSED_PATH 0
152
#define DEF_BOXRADIUS 7
153
#define DEF_DASHLENGTH 4
156
/***********************************************************************/
157
/* NOTE: If you change this you must change _pic_names in e_edit.c too */
158
/***********************************************************************/
160
/* These values are used internally, so changing them doesn't
161
affect any Fig files */
172
#endif /* USE_JPEG */
186
#define NUM_PIC_TYPES LAST_PIC-1
189
#define FileInvalid -2
191
/* Picture sub-type */
193
typedef struct f_pic {
195
enum pictypes subtype;
197
unsigned char *bitmap;
199
struct Cmap cmap[MAX_COLORMAP_SIZE]; /* for GIF/XPM/JPEG files */
200
int numcols; /* number of colors in cmap */
201
int transp; /* transparent color (TRANSP_NONE if none) for GIFs */
203
int size_x, size_y; /* picture size (fig units) */
204
struct f_pos bit_size; /* size of bitmap in pixels */
205
Color color; /* only used for XBM */
206
Pixmap pixmap; /* pixmap created for canvas */
208
pix_width, /* current width of pixmap (pixels) */
209
pix_height, /* current height of pixmap (pixels) */
212
struct f_compound *figure; /* Fig compound if picture type == T_PIC_FIG */
217
extern char EMPTY_PIC[];
219
/* SEE NOTE AT TOP BEFORE CHANGING ANYTHING IN THE f_line STRUCTURE */
223
typedef struct f_line {
240
struct f_arrow *for_arrow;
241
struct f_arrow *back_arrow;
242
int cap_style; /* line cap style - Butt, Round, Bevel */
244
/* THE PRECEDING VARS MUST BE IN THE SAME ORDER IN f_arc, f_line and f_spline */
246
struct f_point *points; /* this must immediately follow cap_style */
248
/* THE PRECEDING VARS MUST BE IN THE SAME ORDER IN f_line and f_spline */
250
int join_style; /* join style - Miter, Round, Bevel */
254
int radius; /* corner radius for T_ARC_BOX */
263
typedef struct f_text {
267
#define T_LEFT_JUSTIFIED 0
268
#define T_CENTER_JUSTIFIED 1
269
#define T_RIGHT_JUSTIFIED 2
271
XFontStruct *fontstruct;
272
float zoom; /* to keep track of when it needs rescaling */
273
int size; /* point size */
276
float angle; /* in radians */
280
#define SPECIAL_TEXT 2
281
#define PSFONT_TEXT 4
282
#define HIDDEN_TEXT 8
284
int ascent; /* Fig units */
285
int length; /* Fig units */
286
int descent; /* from XTextExtents(), not in file */
296
#define MAXFONT(T) (psfont_text(T) ? NUM_FONTS : NUM_LATEX_FONTS)
298
#define rigid_text(t) \
299
(t->flags == DEFAULT \
300
|| (t->flags & RIGID_TEXT))
302
#define special_text(t) \
303
((t->flags != DEFAULT \
304
&& (t->flags & SPECIAL_TEXT)))
306
#define psfont_text(t) \
307
(t->flags != DEFAULT \
308
&& (t->flags & PSFONT_TEXT))
310
#define hidden_text(t) \
311
(t->flags != DEFAULT \
312
&& (t->flags & HIDDEN_TEXT))
314
#define text_length(t) \
315
(hidden_text(t) ? hidden_text_length : t->length)
317
#define using_ps (cur_textflags & PSFONT_TEXT)
319
typedef struct f_shape {
321
struct f_shape *next;
325
/* SEE NOTE AT TOP BEFORE CHANGING ANYTHING IN THE f_spline STRUCTURE */
327
#define int_spline(s) (s->type & 0x2)
328
#define x_spline(s) (s->type & 0x4)
329
#define approx_spline(s) (!(int_spline(s)|x_spline(s)))
330
#define closed_spline(s) (s->type & 0x1)
331
#define open_spline(s) (!(s->type & 0x1))
333
#define S_SPLINE_ANGULAR 0.0
334
#define S_SPLINE_APPROX 1.0
335
#define S_SPLINE_INTERP (-1.0)
337
typedef struct f_spline {
341
#define T_OPEN_APPROX 0
342
#define T_CLOSED_APPROX 1
343
#define T_OPEN_INTERP 2
344
#define T_CLOSED_INTERP 3
345
#define T_OPEN_XSPLINE 4
346
#define T_CLOSED_XSPLINE 5
355
struct f_arrow *for_arrow;
356
struct f_arrow *back_arrow;
359
/* THE PRECEDING VARS MUST BE IN THE SAME ORDER IN f_arc, f_line and f_spline */
362
* "points" are control points. Shape factors are stored in "sfactors".
364
struct f_point *points; /* this must immediately follow cap_style */
366
/* THE PRECEDING VARS MUST BE IN THE SAME ORDER IN f_line and f_spline */
368
struct f_shape *sfactors;
370
struct f_spline *next;
374
typedef struct f_compound {
377
struct f_pos nwcorner;
378
struct f_pos secorner;
379
struct f_line *lines;
380
struct f_ellipse *ellipses;
381
struct f_spline *splines;
382
struct f_text *texts;
385
struct f_compound *parent; /* for "enter/leave compound" */
386
struct f_compound *GABPtr; /* Where original compound came from */
387
struct f_compound *compounds;
388
struct f_compound *next;
392
typedef struct f_linkinfo {
394
struct f_point *endpt;
395
struct f_point *prevpt;
397
struct f_linkinfo *next;
401
/* separate the "type" and the "style" from the cur_arrowtype */
402
#define ARROW_TYPE(x) ((x)==0? 0 : ((x)+1)/2)
403
#define ARROW_STYLE(x) ((x)==0? 0 : ((x)+1)%2)
405
#define ARROW_SIZE sizeof(struct f_arrow)
406
#define POINT_SIZE sizeof(struct f_point)
407
#define CONTROL_SIZE sizeof(struct f_shape)
408
#define ELLOBJ_SIZE sizeof(struct f_ellipse)
409
#define ARCOBJ_SIZE sizeof(struct f_arc)
410
#define LINOBJ_SIZE sizeof(struct f_line)
411
#define TEXOBJ_SIZE sizeof(struct f_text)
412
#define SPLOBJ_SIZE sizeof(struct f_spline)
413
#define COMOBJ_SIZE sizeof(struct f_compound)
414
#define PIC_SIZE sizeof(struct f_pic)
415
#define LINKINFO_SIZE sizeof(struct f_linkinfo)
417
/********************** object codes **********************/
419
#define O_COLOR_DEF 0
426
#define O_END_COMPOUND -O_COMPOUND
427
/* pseudo-object O_FIGURE only for edit panel */
428
#define O_FIGURE 17777
429
#define O_ALL_OBJECT 99
431
/********************* object masks for update ************************/
433
#define M_NONE 0x0000
434
#define M_POLYLINE_POLYGON 0x0001
435
#define M_POLYLINE_LINE 0x0002
436
#define M_POLYLINE_BOX 0x0004 /* includes ARCBOX */
437
#define M_SPLINE_O_APPROX 0x0008
438
#define M_SPLINE_C_APPROX 0x0010
439
#define M_SPLINE_O_INTERP 0x0020
440
#define M_SPLINE_C_INTERP 0x0040
441
#define M_SPLINE_O_XSPLINE 0x0080
442
#define M_SPLINE_C_XSPLINE 0x0100
443
#define M_TEXT_NORMAL 0x0200
444
#define M_TEXT_HIDDEN 0x0400
446
#define M_ELLIPSE 0x1000
447
#define M_COMPOUND 0x2000
449
#define M_TEXT (M_TEXT_HIDDEN | M_TEXT_NORMAL)
450
#define M_SPLINE_O (M_SPLINE_O_APPROX | M_SPLINE_O_INTERP | M_SPLINE_O_XSPLINE)
451
#define M_SPLINE_C (M_SPLINE_C_APPROX | M_SPLINE_C_INTERP | M_SPLINE_C_XSPLINE)
452
#define M_SPLINE_APPROX (M_SPLINE_O_APPROX | M_SPLINE_C_APPROX)
453
#define M_SPLINE_INTERP (M_SPLINE_O_INTERP | M_SPLINE_C_INTERP)
454
#define M_SPLINE_XSPLINE (M_SPLINE_O_XSPLINE | M_SPLINE_C_XSPLINE)
455
#define M_SPLINE (M_SPLINE_APPROX | M_SPLINE_INTERP | M_SPLINE_XSPLINE)
456
#define M_POLYLINE (M_POLYLINE_LINE | M_POLYLINE_POLYGON | M_POLYLINE_BOX)
457
#define M_VARPTS_OBJECT (M_POLYLINE_LINE | M_POLYLINE_POLYGON | M_SPLINE)
458
#define M_OPEN_OBJECT (M_POLYLINE_LINE | M_SPLINE_O | M_ARC)
459
#define M_ROTATE_ANGLE (M_VARPTS_OBJECT | M_ARC | M_TEXT | M_COMPOUND | M_ELLIPSE)
460
#define M_OBJECT (M_ELLIPSE | M_POLYLINE | M_SPLINE | M_TEXT | M_ARC)
461
#define M_NO_TEXT (M_ELLIPSE | M_POLYLINE | M_SPLINE | M_COMPOUND | M_ARC)
462
#define M_ALL (M_OBJECT | M_COMPOUND)
464
/************************ Objects **********************/
466
extern F_compound objects;
468
/************ global working pointers ************/
470
extern F_line *cur_l, *new_l, *old_l;
471
extern F_arc *cur_a, *new_a, *old_a;
472
extern F_ellipse *cur_e, *new_e, *old_e;
473
extern F_text *cur_t, *new_t, *old_t;
474
extern F_spline *cur_s, *new_s, *old_s;
475
extern F_compound *cur_c, *new_c, *old_c;
476
extern F_point *first_point, *cur_point;
477
extern F_linkinfo *cur_links;
479
#endif /* OBJECT_H */