~ubuntu-branches/ubuntu/lucid/graphviz/lucid-security

« back to all changes in this revision

Viewing changes to dotneato/common/types.h

  • Committer: Bazaar Package Importer
  • Author(s): Stephen M Moraco
  • Date: 2002-02-05 18:52:12 UTC
  • Revision ID: james.westby@ubuntu.com-20020205185212-8i04c70te00rc40y
Tags: upstream-1.7.16
ImportĀ upstreamĀ versionĀ 1.7.16

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
    This software may only be used by you under license from AT&T Corp.
 
3
    ("AT&T").  A copy of AT&T's Source Code Agreement is available at
 
4
    AT&T's Internet website having the URL:
 
5
    <http://www.research.att.com/sw/tools/graphviz/license/source.html>
 
6
    If you received this software without first entering into a license
 
7
    with AT&T, you have an infringing copy of this software and cannot use
 
8
    it without violating AT&T's intellectual property rights.
 
9
*/
 
10
 
 
11
#include "pathplan.h"
 
12
 
 
13
typedef unsigned char boolean;
 
14
 
 
15
typedef int (*qsort_cmpf)(const void*, const void*);
 
16
typedef int (*bsearch_cmpf) (const void *, const void *);
 
17
 
 
18
typedef struct Agraph_t graph_t;
 
19
typedef struct Agnode_t node_t;
 
20
typedef struct Agedge_t edge_t;
 
21
typedef struct Agsym_t attrsym_t;
 
22
 
 
23
typedef struct pointf {
 
24
        double          x,y;
 
25
} pointf;
 
26
 
 
27
typedef struct point {
 
28
        int                     x,y;
 
29
} point;
 
30
 
 
31
typedef struct box {
 
32
        point           LL,UR;
 
33
} box;
 
34
 
 
35
typedef struct port_t {                 /* internal edge endpoint specification */
 
36
        point           p;                                      /* aiming point */
 
37
        float           theta;                          /* slope in radians */
 
38
        boolean constrained,defined;
 
39
        unsigned char order;                    /* for mincross */
 
40
} port_t;
 
41
 
 
42
typedef struct path {                   /* internal specification for an edge spline */
 
43
        port_t          start,end;
 
44
        point           *ulpp, *urpp, *llpp, *lrpp;     /* tangents of near splines */
 
45
        int                     nbox;                           /* number of subdivisions */
 
46
        box                     *boxes;                         /* rectangular regions of subdivision */
 
47
        void            *data;
 
48
} path;
 
49
 
 
50
typedef struct bezier {
 
51
        point           *list;
 
52
        int                     size;
 
53
        int                     sflag, eflag;
 
54
        point           sp, ep;
 
55
} bezier;
 
56
 
 
57
typedef struct splines {
 
58
        bezier          *list;
 
59
        int                     size;
 
60
} splines;
 
61
 
 
62
typedef struct textline_t {
 
63
        char                    *str;
 
64
        short                   width;
 
65
        char                    just;
 
66
} textline_t;
 
67
 
 
68
typedef struct textlabel_t {
 
69
        char                    *text,*fontname,*fontcolor;
 
70
        float                   fontsize;
 
71
        pointf                  dimen;
 
72
        point                   p;
 
73
        textline_t              *line;
 
74
        short                   nlines;
 
75
} textlabel_t;
 
76
 
 
77
typedef struct polygon_t {              /* mutable shape information for a node */
 
78
        int                     regular;                        /* true for symmetric shapes */
 
79
        int                     peripheries;            /* number of periphery lines */
 
80
        int                     sides;                          /* number of sides */
 
81
        float           orientation;            /* orientation of shape (+ve degrees) */
 
82
        float           distortion;                     /* distortion factor - as in trapezium */
 
83
        float           skew;                           /* skew factor - as in parallelogram */
 
84
        int                     option;                         /* ROUNDED, DIAGONAL corners, etc. */
 
85
        pointf          *vertices;                  /* array of vertex points */
 
86
} polygon_t;
 
87
 
 
88
typedef struct shape_desc {             /* read-only shape descriptor */
 
89
        char            *name;                                                   /* as read from graph file */
 
90
        void            (*initfn)(node_t *);                    /* initializes shape from node u.shape_info structure */
 
91
        void            (*freefn)(node_t *);                    /* frees  shape from node u.shape_info structure */
 
92
        port_t          (*portfn)(node_t *, char *);    /* finds aiming point and slope of port */
 
93
        int                     (*insidefn)(node_t *, pointf, edge_t*);         /* clips incident edge spline */
 
94
        int                     (*pboxfn)(node_t *, edge_t *, int, box *, int *);               /* finds box path to reach port */
 
95
        void            (*codefn)(node_t *);                    /* emits graphics code for node */
 
96
        polygon_t       *polygon;                                               /* base polygon info */
 
97
} shape_desc;
 
98
 
 
99
typedef struct codegen_t {
 
100
        void     (*reset)(void);
 
101
        void    (*begin_job)(FILE *ofp,graph_t *g, char **lib, char *user, char *info[], point pages);
 
102
        void    (*end_job)(void);
 
103
        void    (*begin_graph)(graph_t* g, box bb, point pb);
 
104
        void    (*end_graph)(void);
 
105
        void    (*begin_page)(point page, double scale, int rot, point offset);
 
106
        void    (*end_page)(void);
 
107
        void    (*begin_cluster)(graph_t *),(*end_cluster)(void); 
 
108
        void    (*begin_nodes)(void),(*end_nodes)(void); 
 
109
        void    (*begin_edges)(void),(*end_edges)(void); 
 
110
        void    (*begin_node)(node_t *),(*end_node)(void);
 
111
        void    (*begin_edge)(edge_t *),(*end_edge)(void);
 
112
        void    (*begin_context)(void),(*end_context)(void);
 
113
        void    (*set_font)(char *fontname, double fontsize);
 
114
        void    (*textline)(point p, textline_t *str);
 
115
        void    (*set_pencolor)(char *name),(*set_fillcolor)(char *name),(*set_style)(char **s);
 
116
        void    (*ellipse)(point p, int rx, int ry, int filled);
 
117
        void    (*polygon)(point *A, int n, int filled);
 
118
        void    (*beziercurve)(point *A, int n, int arrow_at_start, int arrow_at_end);
 
119
        void    (*polyline)(point *A,int n);
 
120
        /* void (*arrowhead)(point p, double theta, double scale, int flag); */
 
121
        boolean bezier_has_arrows;
 
122
        void    (*user_shape)(char *name, point *A, int sides, int filled);
 
123
        void    (*comment)(void* obj, attrsym_t* sym);
 
124
        point   (*textsize)(char *str, char *fontname, double fontsz);
 
125
} codegen_t;
 
126
 
 
127
typedef struct queue {
 
128
        node_t  **store,**limit,**head,**tail;
 
129
} queue;
 
130
 
 
131
typedef struct adjmatrix_t {
 
132
        int             nrows,ncols;
 
133
        char    *data;
 
134
} adjmatrix_t;
 
135
 
 
136
typedef struct rank_t {
 
137
        int                             n;                      /* number of nodes in this rank                 */
 
138
        node_t                  **v;            /* ordered list of nodes in rank                */
 
139
        int                             an;                     /* globally allocated number of nodes   */
 
140
        node_t                  **av;           /* allocated list of nodes in rank              */
 
141
        int                     ht1,ht2;        /* height below/above centerline                */
 
142
        int                     pht1,pht2;      /* as above, but only primitive nodes   */
 
143
        boolean                 candidate;      /* for transpose ()                                             */
 
144
        boolean                 valid;
 
145
        int                             cache_nc;       /* caches number of crossings                   */
 
146
        adjmatrix_t             *flat;
 
147
} rank_t;
 
148
 
 
149
typedef enum engine_e {DOT, NEATO, TWOPI} engine_t;
 
150
 
 
151
typedef struct layout_t {
 
152
        float                   quantum,scale,font_scale_adj;
 
153
        point                   margin, page, size;
 
154
        boolean                 landscape,centered;
 
155
        engine_t                engine;
 
156
} layout_t;
 
157
 
 
158
/* for "record" shapes */
 
159
typedef struct field_t {
 
160
        point           size;                   /* its dimension */
 
161
        box                     b;                              /* its final placement */
 
162
        int                     n_flds; 
 
163
        textlabel_t     *lp;                    /* n_flds == 0 */
 
164
        struct field_t  **fld;          /* n_flds > 0 */
 
165
        int             LR;                                     /* if box list is horizontal (left to right) */
 
166
        char    *id;                            /* user's identifier */
 
167
} field_t;
 
168
 
 
169
typedef struct hsbcolor_t {
 
170
        char                    *name;
 
171
        unsigned char   h,s,b;
 
172
} hsbcolor_t;
 
173
 
 
174
/* possible representations of color in color_t */
 
175
typedef enum color_type_e {HSV_DOUBLE, RGBA_BYTE, RGBA_WORD, CMYK_BYTE} color_type;
 
176
 
 
177
/* color_t can hold a color spec in a choice or representations */
 
178
typedef struct color_s {
 
179
        union {
 
180
                double          HSV[3];
 
181
                unsigned char   rgba[4];
 
182
                unsigned char   cmyk[4];
 
183
                int             rrggbbaa[4];
 
184
        } u;
 
185
        color_type type;
 
186
} color_t;
 
187
 
 
188
typedef struct nlist_t {
 
189
      node_t        **list;
 
190
      int           size;
 
191
} nlist_t;
 
192
 
 
193
typedef struct elist {
 
194
      edge_t        **list;
 
195
      int           size;
 
196
} elist;
 
197
 
 
198
#define elist_fastapp(item,L) do {L.list[L.size++] = item; L.list[L.size] = NULL;} while(0)
 
199
#define elist_append(item,L)  do {L.list = ALLOC(L.size + 2,L.list,edge_t*); L.list[L.size++] = item; L.list[L.size] = NULL;} while(0)
 
200
#define alloc_elist(n,L)      do {L.size = 0; L.list = N_NEW(n + 1,edge_t*); } while (0)
 
201
#define free_list(L)          do {if (L.list) free(L.list);} while (0)
 
202
 
 
203
typedef struct Agraphinfo_t {
 
204
                /* to generate code */
 
205
        layout_t                        *drawing;
 
206
    textlabel_t         *label;         /* if the cluster has a title */
 
207
        box                                     bb;                             /* bounding box */
 
208
        point                           border[4];              /* sizes of margins for graph labels */
 
209
        boolean                         left_to_right,has_edge_labels,has_Latin1char;
 
210
        int                                     ht1,ht2;                /* below and above extremal ranks */
 
211
 
 
212
#ifndef DOT_ONLY
 
213
                /* to place nodes */
 
214
        node_t                          **neato_nlist;
 
215
        int                                     move;
 
216
        double                          **dist,**spring,**sum_t,***t;
 
217
#endif
 
218
#ifndef NEATO_ONLY
 
219
                /* to have subgraphs */
 
220
        int                                     n_cluster;
 
221
        graph_t                         **clust;
 
222
        node_t                          *nlist;
 
223
    rank_t              *rank;
 
224
        /* fast graph node list */
 
225
    nlist_t             comp;
 
226
        /* connected components */
 
227
    node_t              *minset,*maxset;                /* set leaders */
 
228
    long                n_nodes;
 
229
        /* includes virtual */
 
230
    short               minrank,maxrank;
 
231
 
 
232
        /* various flags */
 
233
    boolean             has_flat_edges;
 
234
    boolean             showboxes;
 
235
 
 
236
    int                 nodesep,ranksep;
 
237
    node_t              *ln,*rn;        /* left, right nodes of bounding box */
 
238
 
 
239
 
 
240
        /* for clusters */
 
241
    node_t              *leader,**rankleader;
 
242
    boolean             expanded;
 
243
    char                installed;
 
244
    char                set_type;
 
245
    boolean             exact_ranksep;
 
246
#endif
 
247
 
 
248
} Agraphinfo_t;
 
249
 
 
250
typedef struct Agnodeinfo_t {
 
251
        shape_desc                      *shape;
 
252
        void                            *shape_info;
 
253
        point                           coord;
 
254
        float                           width,height;
 
255
        int                                     ht,lw,rw;
 
256
        textlabel_t                     *label;
 
257
        char                            state;
 
258
    void*               alg;
 
259
 
 
260
#ifndef DOT_ONLY
 
261
        boolean                         pinned;
 
262
        short                           xsize,ysize;
 
263
        int                                     id,heapindex,hops;
 
264
        double                          pos[NDIM],dist;
 
265
#endif
 
266
#ifndef NEATO_ONLY
 
267
    boolean             showboxes,has_port;
 
268
 
 
269
        /* fast graph */
 
270
    char                node_type,mark,onstack;
 
271
    char                ranktype,weight_class;
 
272
    node_t              *next,*prev;
 
273
    elist               in,out,flat_out,flat_in,other;
 
274
    graph_t             *clust;
 
275
 
 
276
        /* for union-find and collapsing nodes */
 
277
    int                 UF_size;
 
278
    node_t              *UF_parent;
 
279
    node_t              *inleaf,*outleaf;
 
280
 
 
281
        /* for placing nodes */
 
282
    int                 rank,order;     /* initially, order = 1 for ordered edges */
 
283
    int                 mval;
 
284
    elist               save_in,save_out;
 
285
 
 
286
        /* for network-simplex */
 
287
    elist               tree_in,tree_out;
 
288
    edge_t              *par;
 
289
    int                 low,lim;
 
290
    int                 priority;
 
291
 
 
292
    double              pad[1];
 
293
#endif
 
294
 
 
295
} Agnodeinfo_t;
 
296
 
 
297
typedef struct Agedgeinfo_t {
 
298
        splines                         *spl;
 
299
        port_t                          tail_port,head_port;    /* might be used someday */
 
300
        textlabel_t                     *label,*head_label,*tail_label;
 
301
        char                            edge_type;
 
302
        char                            label_ontop;
 
303
        edge_t                          *to_orig;                               /* for dot's shapes.c    */
 
304
 
 
305
#ifndef DOT_ONLY
 
306
        float                           factor;
 
307
        float                           dist;
 
308
        Ppolyline_t                     path;
 
309
#endif
 
310
#ifndef NEATO_ONLY
 
311
    boolean             showboxes;
 
312
    boolean             conc_opp_flag;
 
313
    short               xpenalty;
 
314
    int                 weight;
 
315
    int                 cutvalue,tree_index;
 
316
    short               count,minlen;
 
317
        edge_t              *to_virt;
 
318
#endif
 
319
 
 
320
} Agedgeinfo_t;