Initial release of Maemo 5 port of gnuplot
[gnuplot] / term / object.h
1 /*
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
6  *
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.
18  */
19
20 /* This file has been modified for use with Gnuplot 3.6 by
21  * Ian MacPhedran.
22  */
23
24 /* DEFAULT is used for many things - font, color etc */
25
26 #define         DEFAULT               (-1)
27 #define         SOLID_LINE              0
28 #define         DASH_LINE               1
29 #define         DOTTED_LINE             2
30 #define         RUBBER_LINE             3
31 #define         PANEL_LINE              4
32
33 #define         Color                   int
34
35 #define         BLACK                   0
36 #define         BLUE                    1
37 #define         GREEN                   2
38 #define         CYAN                    3
39 #define         RED                     4
40 #define         MAGENTA                 5
41 #define         YELLOW                  6
42 #define         WHITE                   7
43
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.
47 **/
48
49 typedef struct f_point {
50     int             x, y;
51 }
52                 F_point;
53
54 typedef struct f_pos {
55     int             x, y;
56 }
57                 F_pos;
58
59 #define DEF_ARROW_WID (4 * ZOOM_FACTOR)
60 #define DEF_ARROW_HT (8 * ZOOM_FACTOR)
61
62 typedef struct f_arrow {
63     int             type;
64     int             style;
65     float           thickness;
66     float           wid;
67     float           ht;
68 }
69                 F_arrow;
70
71 typedef struct f_ellipse {
72     int             tagged;
73     int             distrib;
74     int             type;
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
79     int             style;
80     int             thickness;
81     Color           pen_color;
82     Color           fill_color;
83     int             fill_style;
84     int             depth;
85     float           style_val;
86     int             pen_style;
87     float           angle;
88     int             direction;
89 #define                                 UNFILLED        -1
90     struct f_pos    center;
91     struct f_pos    radiuses;
92     struct f_pos    start;
93     struct f_pos    end;
94     struct f_ellipse *next;
95 }
96                 F_ellipse;
97
98 /* SEE NOTE AT TOP BEFORE CHANGING ANYTHING IN THE f_arc STRUCTURE */
99
100 typedef struct f_arc {
101     int             tagged;
102     int             distrib;
103     int             type;
104                                 /* note: these arc types are the internal values */
105                                 /* in the file, they are open=1, wedge=2 */
106 #define                                 T_OPEN_ARC              0
107 #define                                 T_PIE_WEDGE_ARC         1
108     int             style;
109     int             thickness;
110     Color           pen_color;
111     Color           fill_color;
112     int             fill_style;
113     int             depth;
114     int             pen_style;
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 */
118     int             cap_style;
119     float           style_val;
120     int             direction;
121     struct {
122         float           x, y;
123     }               center;
124     struct f_pos    point[3];
125     struct f_arc   *next;
126 }
127                 F_arc;
128
129 #define         CLOSED_PATH             0
130 #define         OPEN_PATH               1
131 #define         DEF_BOXRADIUS           7
132 #define         DEF_DASHLENGTH          4
133 #define         DEF_DOTGAP              3
134
135 typedef struct f_pic {
136 #ifndef PATH_MAX
137 #define PATH_MAX 128
138 #endif
139     char            file[PATH_MAX];
140     int             subtype;
141 #define T_PIC_EPS       1
142 #define T_PIC_BITMAP    2
143 #define T_PIC_PIXMAP    3
144 #define T_PIC_GIF       4
145 #define FileInvalid     -2
146     int             flipped;
147     unsigned char   *bitmap;
148     int             numcols;            /* number of colors in cmap */
149     float           hw_ratio;
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;
154 }
155                 F_pic;
156
157 extern char     EMPTY_PIC[];
158
159 /* SEE NOTE AT TOP BEFORE CHANGING ANYTHING IN THE f_line STRUCTURE */
160
161 typedef struct f_line {
162     int             tagged;
163     int             distrib;
164     int             type;
165 #define                                 T_POLYLINE      1
166 #define                                 T_BOX           2
167 #define                                 T_POLYGON       3
168 #define                                 T_ARC_BOX       4
169 #define                                 T_PIC_BOX       5
170     int             style;
171     int             thickness;
172     Color           pen_color;
173     Color           fill_color;
174     int             fill_style;
175     int             depth;
176     int             pen_style;
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 */
181 #define                                 CAP_BUTT        0
182 #define                                 CAP_ROUND       1
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 */
186 #define                                 JOIN_MITER      0
187 #define                                 JOIN_ROUND      1
188 #define                                 JOIN_BEVEL      2
189     float           style_val;
190     int             radius;             /* corner radius for T_ARC_BOX */
191     struct f_pic   *pic;
192     struct f_line  *next;
193 }
194                 F_line;
195
196 typedef struct f_text {
197     int             tagged;
198     int             distrib;
199     int             type;
200 #define                                 T_LEFT_JUSTIFIED        0
201 #define                                 T_CENTER_JUSTIFIED      1
202 #define                                 T_RIGHT_JUSTIFIED       2
203     int             font;
204 /*    PIX_FONT      fontstruct; */
205     int             size;       /* point size */
206     Color           color;
207     int             depth;
208     float           angle;      /* in radians */
209
210     int             flags;
211 #define                                 RIGID_TEXT              1
212 #define                                 SPECIAL_TEXT            2
213 #define                                 PSFONT_TEXT             4
214 #define                                 HIDDEN_TEXT             8
215
216     int             ascent;     /* Fig units */
217     int             length;     /* Fig units */
218     int             descent;    /* from XTextExtents(), not in file */
219     int             base_x;
220     int             base_y;
221     int             pen_style;
222     char           *cstring;
223     struct f_text  *next;
224 }
225                 F_text;
226
227 #define MAXFONT(T) (psfont_text(T) ? NUM_FONTS : NUM_LATEX_FONTS)
228
229 #define         rigid_text(t) \
230                         (t->flags == DEFAULT \
231                                 || (t->flags & RIGID_TEXT))
232
233 #define         special_text(t) \
234                         ((t->flags != DEFAULT \
235                                 && (t->flags & SPECIAL_TEXT)))
236
237 #define         psfont_text(t) \
238                         (t->flags != DEFAULT \
239                                 && (t->flags & PSFONT_TEXT))
240
241 #define         hidden_text(t) \
242                         (t->flags != DEFAULT \
243                                 && (t->flags & HIDDEN_TEXT))
244
245 #define         text_length(t) \
246                         (hidden_text(t) ? hidden_text_length : t->length)
247
248 #define         using_ps        (cur_textflags & PSFONT_TEXT)
249
250 typedef struct f_control {
251     float           lx, ly, rx, ry;
252     struct f_control *next;
253 }
254                 F_control;
255
256 /* SEE NOTE AT TOP BEFORE CHANGING ANYTHING IN THE f_spline STRUCTURE */
257
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))
262
263 typedef struct f_spline {
264     int             tagged;
265     int             distrib;
266     int             type;
267 #define                                 T_OPEN_NORMAL   0
268 #define                                 T_CLOSED_NORMAL 1
269 #define                                 T_OPEN_INTERP   2
270 #define                                 T_CLOSED_INTERP 3
271     int             style;
272     int             thickness;
273     Color           pen_color;
274     Color           fill_color;
275     int             fill_style;
276     int             depth;
277     int             pen_style;
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 */
281     int             cap_style;
282     /*
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.
286      */
287     struct f_point *points;     /* this must immediately follow cap_style */
288     float           style_val;
289     struct f_control *controls;
290     struct f_spline *next;
291 }
292                 F_spline;
293
294 typedef struct f_compound {
295     int             tagged;
296     int             distrib;
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;
303     struct f_arc   *arcs;
304     struct f_compound *compounds;
305     struct f_compound *next;
306 }
307                 F_compound;
308
309 typedef struct f_linkinfo {
310     struct f_line  *line;
311     struct f_point *endpt;
312     struct f_point *prevpt;
313     int             two_pts;
314     struct f_linkinfo *next;
315 }
316                 F_linkinfo;
317
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)
321
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)
333
334 /**********************  object codes  **********************/
335
336 #define         O_COLOR_DEF     0
337 #define         O_ELLIPSE       1
338 #define         O_POLYLINE      2
339 #define         O_SPLINE        3
340 /* HBB 990329: quick hack: 'O_TEXT' is in use by <fcntl.h> header
341  * on DOS/Windows platforms. Renamed to OBJ_TEXT */
342 #define         OBJ_TEXT          4
343 #define         O_ARC           5
344 #define         O_COMPOUND      6
345 #define         O_END_COMPOUND  -O_COMPOUND
346 #define         O_ALL_OBJECT    99
347
348 /********************* object masks for update  ************************/
349
350 #define M_NONE                  0x000
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
360 #define M_ARC                   0x200
361 #define M_ELLIPSE               0x400
362 #define M_COMPOUND              0x800
363
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)
378
379 /************************  Objects  **********************/
380
381 extern F_compound objects;
382
383 /************  global working pointers ************/
384
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;
393
394 /*************** object attribute settings ***********/
395
396 /*  Lines  */
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;
410
411 /* Text */
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;
417
418 /* Misc */
419 extern float    cur_elltextangle;