~ubuntu-branches/ubuntu/trusty/xfig/trusty

« back to all changes in this revision

Viewing changes to object.h

  • Committer: Bazaar Package Importer
  • Author(s): Roland Rosenfeld
  • Date: 2002-03-22 10:39:49 UTC
  • Revision ID: james.westby@ubuntu.com-20020322103949-63082hoxulq6n7u1
Tags: upstream-3.2.3.d-rel
ImportĀ upstreamĀ versionĀ 3.2.3.d-rel

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
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
 
6
 *
 
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.
 
15
 *
 
16
 */
 
17
 
 
18
#ifndef OBJECT_H
 
19
#define OBJECT_H
 
20
 
 
21
/* values to signify color used for transparent GIF color */
 
22
 
 
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) */
 
26
 
 
27
/* DEFAULT is used for many things - font, color etc */
 
28
 
 
29
#define         DEFAULT               (-1)
 
30
 
 
31
#define         SOLID_LINE              0
 
32
#define         DASH_LINE               1
 
33
#define         DOTTED_LINE             2
 
34
#define         DASH_DOT_LINE           3
 
35
#define         DASH_2_DOTS_LINE        4
 
36
#define         DASH_3_DOTS_LINE        5
 
37
 
 
38
#define         RUBBER_LINE             11
 
39
#define         PANEL_LINE              12
 
40
 
 
41
#define         BLACK                   0
 
42
#define         BLUE                    1
 
43
#define         GREEN                   2
 
44
#define         CYAN                    3
 
45
#define         RED                     4
 
46
#define         MAGENTA                 5
 
47
#define         YELLOW                  6
 
48
#define         WHITE                   7
 
49
#define         GREEN4                  12
 
50
 
 
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.
 
56
**/
 
57
 
 
58
typedef struct f_point {
 
59
    int             x, y;
 
60
    struct f_point *next;
 
61
}
 
62
                F_point;
 
63
 
 
64
typedef struct f_pos {
 
65
    int             x, y;
 
66
}
 
67
                F_pos;
 
68
 
 
69
#define DEF_ARROW_WID 4
 
70
#define DEF_ARROW_HT 8
 
71
 
 
72
typedef struct f_arrow {
 
73
    int             type;
 
74
    int             style;
 
75
    float           thickness;
 
76
    float           wd;
 
77
    float           ht;
 
78
}
 
79
                F_arrow;
 
80
 
 
81
/* Ellipse object */
 
82
 
 
83
typedef struct f_ellipse {
 
84
    int             tagged;
 
85
    int             distrib;
 
86
    int             type;
 
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
 
91
    int             style;
 
92
    int             thickness;
 
93
    Color           pen_color;
 
94
    Color           fill_color;
 
95
    int             fill_style;
 
96
    int             depth;
 
97
    int             pen_style;
 
98
    float           style_val;
 
99
    float           angle;
 
100
    int             direction;
 
101
#define                                 UNFILLED        -1
 
102
    struct f_pos    center;
 
103
    struct f_pos    radiuses;
 
104
    struct f_pos    start;
 
105
    struct f_pos    end;
 
106
    char           *comments;
 
107
    struct f_ellipse *next;
 
108
}
 
109
                F_ellipse;
 
110
 
 
111
/* SEE NOTE AT TOP BEFORE CHANGING ANYTHING IN THE f_arc STRUCTURE */
 
112
 
 
113
/* Arc object */
 
114
 
 
115
typedef struct f_arc {
 
116
    int             tagged;
 
117
    int             distrib;
 
118
    int             type;
 
119
                                /* note: these arc types are the internal values */
 
120
                                /* in the file, they are open=1, wedge=2 */
 
121
#define                                 T_OPEN_ARC              0
 
122
#define                                 T_PIE_WEDGE_ARC         1
 
123
    int             style;
 
124
    int             thickness;
 
125
    Color           pen_color;
 
126
    Color           fill_color;
 
127
    int             fill_style;
 
128
    int             depth;
 
129
    int             pen_style;
 
130
    float           style_val;
 
131
    struct f_arrow *for_arrow;
 
132
    struct f_arrow *back_arrow;
 
133
    int             cap_style;
 
134
#define                                 CAP_BUTT        0
 
135
#define                                 CAP_ROUND       1
 
136
#define                                 CAP_PROJECT     2
 
137
 
 
138
/* THE PRECEDING VARS MUST BE IN THE SAME ORDER IN f_arc, f_line and f_spline */
 
139
 
 
140
    int             direction;
 
141
    struct {
 
142
        float           x, y;
 
143
    }               center;
 
144
    struct f_pos    point[3];
 
145
    char           *comments;
 
146
    struct f_arc   *next;
 
147
}
 
148
                F_arc;
 
149
 
 
150
#define         CLOSED_PATH             0
 
151
#define         OPEN_PATH               1
 
152
#define         DEF_BOXRADIUS           7
 
153
#define         DEF_DASHLENGTH          4
 
154
#define         DEF_DOTGAP              3
 
155
 
 
156
/***********************************************************************/
 
157
/* NOTE: If you change this you must change _pic_names in e_edit.c too */
 
158
/***********************************************************************/
 
159
 
 
160
/* These values are used internally, so changing them doesn't
 
161
   affect any Fig files */
 
162
 
 
163
enum pictypes {
 
164
        T_PIC_NONE,
 
165
#ifdef V4_0
 
166
        T_PIC_FIG,
 
167
#endif /* V4_0 */
 
168
        T_PIC_EPS,
 
169
        T_PIC_GIF,
 
170
#ifdef USE_JPEG
 
171
        T_PIC_JPEG,
 
172
#endif /* USE_JPEG */
 
173
        T_PIC_PCX,
 
174
#ifdef USE_PNG
 
175
        T_PIC_PNG,
 
176
#endif /* USE_PNG */
 
177
        T_PIC_PPM,
 
178
        T_PIC_TIF,
 
179
        T_PIC_XBM,
 
180
#ifdef USE_XPM
 
181
        T_PIC_XPM,
 
182
#endif /* USE_XPM */
 
183
        LAST_PIC
 
184
     } ;
 
185
 
 
186
#define NUM_PIC_TYPES LAST_PIC-1
 
187
 
 
188
#define PicSuccess      1
 
189
#define FileInvalid    -2
 
190
 
 
191
/* Picture sub-type */
 
192
 
 
193
typedef struct f_pic {
 
194
    char            file[PATH_MAX];
 
195
    enum pictypes   subtype;
 
196
    int             flipped;
 
197
    unsigned char  *bitmap;
 
198
    Pixmap          mask;
 
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 */
 
202
    float           hw_ratio;
 
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 */
 
207
    int             pix_rotation,
 
208
                    pix_width,          /* current width of pixmap (pixels) */
 
209
                    pix_height,         /* current height of pixmap (pixels) */
 
210
                    pix_flipped;
 
211
#ifdef V4_0
 
212
    struct f_compound *figure;          /* Fig compound if picture type == T_PIC_FIG */
 
213
#endif
 
214
}
 
215
                F_pic;
 
216
 
 
217
extern char     EMPTY_PIC[];
 
218
 
 
219
/* SEE NOTE AT TOP BEFORE CHANGING ANYTHING IN THE f_line STRUCTURE */
 
220
 
 
221
/* Line object */
 
222
 
 
223
typedef struct f_line {
 
224
    int             tagged;
 
225
    int             distrib;
 
226
    int             type;
 
227
#define                                 T_POLYLINE      1
 
228
#define                                 T_BOX           2
 
229
#define                                 T_POLYGON       3
 
230
#define                                 T_ARC_BOX       4
 
231
#define                                 T_PICTURE       5
 
232
    int             style;
 
233
    int             thickness;
 
234
    Color           pen_color;
 
235
    Color           fill_color;
 
236
    int             fill_style;
 
237
    int             depth;
 
238
    int             pen_style;
 
239
    float           style_val;
 
240
    struct f_arrow *for_arrow;
 
241
    struct f_arrow *back_arrow;
 
242
    int             cap_style;  /* line cap style - Butt, Round, Bevel */
 
243
 
 
244
/* THE PRECEDING VARS MUST BE IN THE SAME ORDER IN f_arc, f_line and f_spline */
 
245
 
 
246
    struct f_point *points;     /* this must immediately follow cap_style */
 
247
 
 
248
/* THE PRECEDING VARS MUST BE IN THE SAME ORDER IN f_line and f_spline */
 
249
 
 
250
    int             join_style;         /* join style - Miter, Round, Bevel */
 
251
#define                                 JOIN_MITER      0
 
252
#define                                 JOIN_ROUND      1
 
253
#define                                 JOIN_BEVEL      2
 
254
    int             radius;     /* corner radius for T_ARC_BOX */
 
255
    struct f_pic   *pic;
 
256
    char           *comments;
 
257
    struct f_line  *next;
 
258
}
 
259
                F_line;
 
260
 
 
261
/* Text object */
 
262
 
 
263
typedef struct f_text {
 
264
    int             tagged;
 
265
    int             distrib;
 
266
    int             type;
 
267
#define                                 T_LEFT_JUSTIFIED        0
 
268
#define                                 T_CENTER_JUSTIFIED      1
 
269
#define                                 T_RIGHT_JUSTIFIED       2
 
270
    int             font;
 
271
    XFontStruct    *fontstruct;
 
272
    float           zoom;       /* to keep track of when it needs rescaling */
 
273
    int             size;       /* point size */
 
274
    Color           color;
 
275
    int             depth;
 
276
    float           angle;      /* in radians */
 
277
 
 
278
    int             flags;
 
279
#define                                 RIGID_TEXT              1
 
280
#define                                 SPECIAL_TEXT            2
 
281
#define                                 PSFONT_TEXT             4
 
282
#define                                 HIDDEN_TEXT             8
 
283
 
 
284
    int             ascent;     /* Fig units */
 
285
    int             length;     /* Fig units */
 
286
    int             descent;    /* from XTextExtents(), not in file */
 
287
    int             base_x;
 
288
    int             base_y;
 
289
    int             pen_style;
 
290
    char           *cstring;
 
291
    char           *comments;
 
292
    struct f_text  *next;
 
293
}
 
294
                F_text;
 
295
 
 
296
#define MAXFONT(T) (psfont_text(T) ? NUM_FONTS : NUM_LATEX_FONTS)
 
297
 
 
298
#define         rigid_text(t) \
 
299
                        (t->flags == DEFAULT \
 
300
                                || (t->flags & RIGID_TEXT))
 
301
 
 
302
#define         special_text(t) \
 
303
                        ((t->flags != DEFAULT \
 
304
                                && (t->flags & SPECIAL_TEXT)))
 
305
 
 
306
#define         psfont_text(t) \
 
307
                        (t->flags != DEFAULT \
 
308
                                && (t->flags & PSFONT_TEXT))
 
309
 
 
310
#define         hidden_text(t) \
 
311
                        (t->flags != DEFAULT \
 
312
                                && (t->flags & HIDDEN_TEXT))
 
313
 
 
314
#define         text_length(t) \
 
315
                        (hidden_text(t) ? hidden_text_length : t->length)
 
316
 
 
317
#define         using_ps        (cur_textflags & PSFONT_TEXT)
 
318
 
 
319
typedef struct f_shape {
 
320
    double s;
 
321
    struct f_shape *next;
 
322
}
 
323
                F_sfactor;
 
324
 
 
325
/* SEE NOTE AT TOP BEFORE CHANGING ANYTHING IN THE f_spline STRUCTURE */
 
326
 
 
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))
 
332
 
 
333
#define S_SPLINE_ANGULAR 0.0
 
334
#define S_SPLINE_APPROX 1.0
 
335
#define S_SPLINE_INTERP (-1.0)
 
336
 
 
337
typedef struct f_spline {
 
338
    int             tagged;
 
339
    int             distrib;
 
340
    int             type;
 
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
 
347
    int             style;
 
348
    int             thickness;
 
349
    Color           pen_color;
 
350
    Color           fill_color;
 
351
    int             fill_style;
 
352
    int             depth;
 
353
    int             pen_style;
 
354
    float           style_val;
 
355
    struct f_arrow *for_arrow;
 
356
    struct f_arrow *back_arrow;
 
357
    int             cap_style;
 
358
 
 
359
/* THE PRECEDING VARS MUST BE IN THE SAME ORDER IN f_arc, f_line and f_spline */
 
360
 
 
361
    /*
 
362
     * "points" are control points. Shape factors are stored in "sfactors".
 
363
     */
 
364
    struct f_point *points;     /* this must immediately follow cap_style */
 
365
 
 
366
/* THE PRECEDING VARS MUST BE IN THE SAME ORDER IN f_line and f_spline */
 
367
 
 
368
    struct f_shape *sfactors;
 
369
    char           *comments;
 
370
    struct f_spline *next;
 
371
}
 
372
                F_spline;
 
373
 
 
374
typedef struct f_compound {
 
375
    int             tagged;
 
376
    int             distrib;
 
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;
 
383
    struct f_arc   *arcs;
 
384
    char           *comments;
 
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;
 
389
}
 
390
                F_compound;
 
391
 
 
392
typedef struct f_linkinfo {
 
393
    struct f_line  *line;
 
394
    struct f_point *endpt;
 
395
    struct f_point *prevpt;
 
396
    int             two_pts;
 
397
    struct f_linkinfo *next;
 
398
}
 
399
                F_linkinfo;
 
400
 
 
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)
 
404
 
 
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)
 
416
 
 
417
/**********************  object codes  **********************/
 
418
 
 
419
#define         O_COLOR_DEF     0
 
420
#define         O_ELLIPSE       1
 
421
#define         O_POLYLINE      2
 
422
#define         O_SPLINE        3
 
423
#define         O_TEXT          4
 
424
#define         O_ARC           5
 
425
#define         O_COMPOUND      6
 
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
 
430
 
 
431
/********************* object masks for update  ************************/
 
432
 
 
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
 
445
#define M_ARC                   0x0800
 
446
#define M_ELLIPSE               0x1000
 
447
#define M_COMPOUND              0x2000
 
448
 
 
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)
 
463
 
 
464
/************************  Objects  **********************/
 
465
 
 
466
extern F_compound objects;
 
467
 
 
468
/************  global working pointers ************/
 
469
 
 
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;
 
478
 
 
479
#endif /* OBJECT_H */