source: tags/initial/fig2dev/object.h

Last change on this file was 2, checked in by oldcode, 24 years ago

Initial revision

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 6.4 KB
Line 
1/*
2 * TransFig: Facility for Translating Fig code
3 * Copyright (c) 1985 Supoj Sutantavibul
4 * Copyright (c) 1991 Micah Beck
5 *
6 * Permission to use, copy, modify, distribute, and sell this software and its
7 * documentation for any purpose is hereby granted without fee, provided that
8 * the above copyright notice appear in all copies and that both that
9 * copyright notice and this permission notice appear in supporting
10 * documentation. The authors make no representations about the suitability
11 * of this software for any purpose.  It is provided "as is" without express
12 * or implied warranty.
13 *
14 * THE AUTHORS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
15 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
16 * EVENT SHALL THE AUTHORS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
17 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
18 * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
19 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
20 * PERFORMANCE OF THIS SOFTWARE.
21 *
22 */
23
24#define         DEFAULT                         (-1)
25
26typedef         struct f_point {
27                        int                     x, y;
28                        struct f_point          *next;
29                        }
30                F_point;
31
32typedef         struct f_pos {
33                        int                     x, y;
34                        }
35                F_pos;
36
37typedef         struct f_arrow {
38                        int                     type;
39                        int                     style;
40                        double                  thickness;
41                        double                  wid;
42                        double                  ht;
43                        }
44                F_arrow;
45
46typedef         struct f_ellipse {
47                        int                     type;
48#define                                 T_ELLIPSE_BY_RAD        1
49#define                                 T_ELLIPSE_BY_DIA        2
50#define                                 T_CIRCLE_BY_RAD         3
51#define                                 T_CIRCLE_BY_DIA         4
52                        int                     style;
53                        int                     thickness;
54                        int                     color;
55#define                                 BLACK_COLOR             0
56#define                                 BLUE_COLOR              1
57#define                                 GREEN_COLOR             2
58#define                                 CYAN_COLOR              3
59#define                                 RED_COLOR               4
60#define                                 MAGENTA_COLOR           5
61#define                                 YELLOW_COLOR            6
62#define                                 WHITE_COLOR             7
63                        int                     depth;
64                        int                     direction;
65                        double                  style_val;
66                        double                  angle;
67                        int                     pen;
68                        int                     area_fill;
69#define                                 UNFILLED        0
70#define                                 WHITE_FILL      1
71#define                                 BLACK_FILL      21
72                        struct f_pos            center;
73                        struct f_pos            radiuses;
74                        struct f_pos            start;
75                        struct f_pos            end;
76                        struct f_ellipse        *next;
77                        }
78                F_ellipse;
79
80typedef         struct f_arc {
81                        int                     type;
82#define                                 T_3_POINTS_ARC          1
83                        int                     style;
84                        int                     thickness;
85                        int                     color;
86                        int                     depth;
87                        int                     pen;
88                        int                     area_fill;
89                        double                  style_val;
90                        int                     direction;
91                        struct f_arrow          *for_arrow;
92                        struct f_arrow          *back_arrow;
93                        struct {double x, y;}   center;
94                        struct f_pos            point[3];
95                        struct f_arc            *next;
96                        }
97                F_arc;
98
99typedef         struct f_line {
100                        int                     type;
101#define                                 T_POLYLINE      1
102#define                                 T_BOX           2
103#define                                 T_POLYGON       3
104#define                                 T_ARC_BOX       4
105#define                                 T_EPS_BOX       5
106
107                        int                     style;
108                        int                     thickness;
109                        int                     color;
110                        int                     depth;
111                        double                  style_val;
112                        int                     pen;
113                        int                     area_fill;
114                        int                     radius; /* for T_ARC_BOX */
115                        struct f_arrow          *for_arrow;
116                        struct f_arrow          *back_arrow;
117                        struct f_point          *points;
118                        struct f_eps            *eps;
119                        struct f_line           *next;
120                        }
121                F_line;
122
123typedef struct f_eps {
124    char            file[256];
125    int             flipped;
126    unsigned char  *bitmap;
127    float           hw_ratio;
128    struct f_pos    bit_size;
129    int             pix_rotation, pix_width, pix_height, pix_flipped;
130}
131                F_eps;
132
133extern char EMPTY_EPS[];
134
135typedef         struct f_text {
136                        int                     type;
137#define                                 T_LEFT_JUSTIFIED        0
138#define                                 T_CENTER_JUSTIFIED      1
139#define                                 T_RIGHT_JUSTIFIED       2
140                        int                     font;
141#define                                 DEFAULT_FONT            0
142#define                                 ROMAN_FONT              1
143#define                                 BOLD_FONT               2
144#define                                 ITALIC_FONT             3
145#define                                 MODERN_FONT             4
146#define                                 TYPEWRITER_FONT         5
147#define                                 MAX_FONT                5
148                        double                  size;   /* point size */
149                        int                     color;
150                        int                     depth;
151                        double                  angle;  /* in radian */
152                        int                     flags;
153#define                                 RIGID_TEXT      1       
154#define                                 SPECIAL_TEXT    2
155#define                                 PSFONT_TEXT     4
156                        double                  height; /* pixels */
157                        double                  length; /* pixels */
158                        int                     base_x;
159                        int                     base_y;
160                        int                     pen;
161                        char                    *cstring;
162                        struct f_text           *next;
163                        }
164                F_text;
165
166#define MAX_PSFONT      35
167#define MAXFONT(T) (psfont_text(T) ? MAX_PSFONT : MAX_FONT)
168
169#define         rigid_text(t) \
170                        (t->flags == DEFAULT \
171                                || (t->flags & RIGID_TEXT))
172
173#define         special_text(t) \
174                        ((t->flags != DEFAULT \
175                                && (t->flags & SPECIAL_TEXT)))
176
177#define         psfont_text(t) \
178                        (t->flags != DEFAULT \
179                                && (t->flags & PSFONT_TEXT))
180
181typedef         struct f_control {
182                        double                  lx, ly, rx, ry;
183                        struct f_control        *next;
184                        }
185                F_control;
186
187#define         int_spline(s)           (s->type & 0x2)
188#define         normal_spline(s)        (!(s->type & 0x2))
189#define         closed_spline(s)        (s->type & 0x1)
190#define         open_spline(s)          (!(s->type & 0x1))
191
192typedef         struct f_spline {
193                        int                     type;
194#define                                 T_OPEN_NORMAL           0
195#define                                 T_CLOSED_NORMAL         1
196#define                                 T_OPEN_INTERPOLATED     2
197#define                                 T_CLOSED_INTERPOLATED   3
198                        int                     style;
199                        int                     thickness;
200                        int                     color;
201                        int                     depth;
202                        double                  style_val;
203                        int                     pen;
204                        int                     area_fill;
205                        struct f_arrow          *for_arrow;
206                        struct f_arrow          *back_arrow;
207                        /*
208                        For T_OPEN_NORMAL and T_CLOSED_NORMAL points
209                        are control points while they are knots for
210                        T_OPEN_INTERPOLATED and T_CLOSED_INTERPOLTED
211                        whose control points are stored in controls.
212                        */
213                        struct f_point          *points;
214                        struct f_control        *controls;
215                        struct f_spline         *next;
216                        }
217                F_spline;
218
219typedef         struct f_compound {
220                        struct f_pos            nwcorner;
221                        struct f_pos            secorner;
222                        struct f_line           *lines;
223                        struct f_ellipse        *ellipses;
224                        struct f_spline         *splines;
225                        struct f_text           *texts;
226                        struct f_arc            *arcs;
227                        struct f_compound       *compounds;
228                        struct f_compound       *next;
229                        }
230                F_compound;
231
232#define         ARROW_SIZE              sizeof(struct f_arrow)
233#define         POINT_SIZE              sizeof(struct f_point)
234#define         CONTROL_SIZE            sizeof(struct f_control)
235#define         ELLOBJ_SIZE             sizeof(struct f_ellipse)
236#define         ARCOBJ_SIZE             sizeof(struct f_arc)
237#define         LINOBJ_SIZE             sizeof(struct f_line)
238#define         EPS_SIZE                sizeof(struct f_eps)
239#define         TEXOBJ_SIZE             sizeof(struct f_text)
240#define         SPLOBJ_SIZE             sizeof(struct f_spline)
241#define         COMOBJ_SIZE             sizeof(struct f_compound)
242
243/**********************  object codes  **********************/
244
245#define         O_ELLIPSE               1
246#define         O_POLYLINE              2
247#define         O_SPLINE                3
248#define         O_TEXT                  4
249#define         O_ARC                   5
250#define         O_COMPOUND              6
251#define         O_END_COMPOUND          (-O_COMPOUND)
252#define         O_ALL_OBJECT            99
253
254/************  object styles (except for f_text)  ************/
255
256#define         SOLID_LINE              0
257#define         DASH_LINE               1
258#define         DOTTED_LINE             2
259
260#define         CLOSED_PATH             0
261#define         OPEN_PATH               1
Note: See TracBrowser for help on using the repository browser.