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

« back to all changes in this revision

Viewing changes to incr/incr.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
#ifndef AGINCR_H
 
2
#define AGINCR_H
 
3
 
 
4
/* Abstract interface for an incremental layout engine.
 
5
 * "Downcall" means from the canvas manager to layout engine.
 
6
 * "Upcall" means a callback from layout engine to client.
 
7
 */
 
8
 
 
9
#ifdef HAVE_CONFIG_H
 
10
#include "gvconfig.h"
 
11
#endif
 
12
 
 
13
#include <agraph.h>
 
14
 
 
15
#ifdef HAVE_VALUES_H
 
16
#include <values.h>
 
17
#else
 
18
#include <limits.h>
 
19
#ifndef MAXINT
 
20
#define MAXINT INT_MAX
 
21
#endif
 
22
#include <float.h>
 
23
#ifndef MAXDOUBLE
 
24
#define MAXDOUBLE DBL_MAX
 
25
#endif
 
26
#ifndef MAXFLOAT
 
27
#define MAXFLOAT FLT_MAX
 
28
#endif
 
29
#endif
 
30
 
 
31
/* Coordinates and offsets are stored as floats.  The unit (pixels,
 
32
 * inches, centimeters, etc.) is entirely up to the client.  Layout
 
33
 * engines must work in any scale the client chooses.  The coordinate
 
34
 * system places the origin at the upper left-hand corner of the canvas.
 
35
 * Axes are positive right and down.
 
36
 */
 
37
 
 
38
typedef unsigned char ilbool;
 
39
typedef struct ilcoord_s {double x,y;} ilcoord_t;
 
40
typedef struct {ilcoord_t ll,ur;} ilrect_t;
 
41
typedef ilcoord_t       ildelta;        /* no _t ? */
 
42
typedef ilrect_t        ilbox;
 
43
 
 
44
typedef struct ilshape_s ilshape_t;
 
45
typedef struct ilcurve_s ilcurve_t;
 
46
 
 
47
/* Types of diagram objects. */
 
48
typedef enum {ILNODE=AGNODE, ILEDGE=AGEDGE, ILHYPER, ILVIEW=AGRAPH} ILtag_t;
 
49
 
 
50
/* Specifiers for nodes, edges, hyperedges, and layouts.
 
51
 * These descriptors are passed in both down- and up-calls.
 
52
 * The client is responsible for storage management.  The descriptor
 
53
 * must be kept live (and at the same address) from the time of new
 
54
 * object insertion until a delete callback is received.
 
55
 *
 
56
 * Client can add its own fields to the base structure.
 
57
 *
 
58
 * immutable - stays the same for the lifetime of the object.
 
59
 * mutable - may be updated by client or engine (unless otherwise restricted.)
 
60
 * client informs engine of changes by calling its mod() function.
 
61
 */
 
62
 
 
63
/* generic object/event specifier */
 
64
typedef struct ILobj_s {
 
65
        ILtag_t         tag;
 
66
} ILobj_t;
 
67
 
 
68
#define IL_UPD_MOVE                     (1 << 0)
 
69
#define IL_UPD_NAIL                     (1 << 1)
 
70
#define IL_UPD_SHAPE            (1 << 2)
 
71
#define IL_UPD_TAIL                     (1 << 3)
 
72
#define IL_UPD_HEAD                     (1 << 4)
 
73
#define IL_UPD_LENGTH           (1 << 5)
 
74
#define IL_UPD_COST                     (1 << 6)
 
75
#define IL_UPD_WIDTH            (1 << 7)
 
76
#define IL_UPD_CONSTRAINT       (1 << 8)
 
77
#define IL_UPD_NAILX            (1 << 9)
 
78
#define IL_UPD_NAILY            (1 << 10)
 
79
 
 
80
/* node event specifier */
 
81
typedef struct ILnode_s {
 
82
        ILobj_t         base;
 
83
        unsigned long   update;         /* owned by both, mutable                               */
 
84
        ilcoord_t       pos;            /* owned by both, mutable                               */
 
85
        ilbool          pos_valid;      /* owned by both, mutable               */
 
86
        ilshape_t       *shape;         /* owned by application, resize allowed */
 
87
} ILnode_t;
 
88
 
 
89
/* an endpoint of an edge or hyperedge */
 
90
typedef struct ILcon_s {        /* owned by application, immutable for now */
 
91
        ILobj_t         *term;          /* usually node, but may be other types */
 
92
        ilcoord_t       port;           /* offset from center of object                 */
 
93
        ilbool          clipped;        /* owned by application                                 */
 
94
} ILcon_t;
 
95
 
 
96
/* edge specifier */
 
97
typedef struct ILedge_s {
 
98
        ILobj_t         base;           /* owned by application, immutable      */
 
99
        ILcon_t         tail, head;     /* owned by application, immutable      */
 
100
        float           width;          /* owned by application, mutable        */
 
101
        float           length_hint;/* owned by application, mutable            */
 
102
        float           cost;           /* owned by application, mutable                */
 
103
        /* how to draw the edge- a hint in downcall, return value in upcall.*/
 
104
        ilshape_t       *pos;           /* owned by both, mutable                               */
 
105
        ilbool          constraint;     /* owned by application, immutable              */
 
106
        unsigned long   update;         /* owned by both, mutable                               */
 
107
} ILedge_t;
 
108
 
 
109
typedef struct ILhyper_s {              /* this is not finished yet */
 
110
        ILobj_t         base;
 
111
        int                     subtype;        /* 0 = primitive, others are engine dependent,  */
 
112
        ilshape_t       *pos;           /* how to draw */
 
113
        int                     n;                      /* number of terminals */
 
114
        ILcon_t         *V;                     /* list of terminals */
 
115
} ILhyper_t;
 
116
 
 
117
/* event/callback function */
 
118
typedef struct ILview_s ILview_t;               /* forward decl */
 
119
typedef ilbool (*ILevf_t)(ILview_t *view, ILobj_t *spec);
 
120
 
 
121
/* A client defines this structure to create a new view.  The client must
 
122
 * maintain this struct for the lifetime of the view, but it's OK to share
 
123
 * between multiple views.
 
124
 */
 
125
struct ILview_s {
 
126
        ILobj_t         base;                   /* defined by clients, immutable. */
 
127
 
 
128
        /* If this flag is TRUE, the engine makes callbacks while
 
129
         * executing graph operations.  If FALSE, callbacks are
 
130
         * only given on demand.  This allows switching between
 
131
         * online and offline graph update.
 
132
         */
 
133
        ilbool          enable_immediate_callbacks;     /* owned by client, mutable */
 
134
 
 
135
        /* client call back functions */
 
136
        ILevf_t         ins;                    /* owned by clients, mutable */
 
137
        ILevf_t         mod;                    /* owned by clients, mutable */
 
138
        ILevf_t         del;                    /* owned by clients, mutable */
 
139
 
 
140
        /* quanitization unit for coordinates */
 
141
        float           resolution;             /* owned by clients, immutable. */
 
142
 
 
143
        /* minimum separation between nodes */
 
144
        ildelta         separation;             /* owned by clients, immutable. */
 
145
 
 
146
        /* desired bounding box, if available, else (0,0) */
 
147
        ilcoord_t       max_bb;
 
148
 
 
149
        /* actual bounding box */
 
150
        ilrect_t        actual_bb;
 
151
 
 
152
        /* a broad hint about time spent per iteration */
 
153
        float           ticks;                  /* owned by clients, mutable */
 
154
 
 
155
        struct engview_s *pvt;                  /* owned by engines, immutable */
 
156
};
 
157
 
 
158
/* Interface to a layout engine. */
 
159
typedef struct ILengine_s {
 
160
        ilbool          (*open)(ILview_t *view);
 
161
        void            (*close)(ILview_t *view);
 
162
 
 
163
        ILevf_t         ins;
 
164
        ILevf_t         mod;
 
165
        ILevf_t         del;
 
166
 
 
167
        /* Issue all pending callbacks.  Return TRUE if there were any. */
 
168
        ilbool          (*callback)(ILview_t *view);
 
169
 
 
170
        /* Look up spec from model node, edge, or subgraph */
 
171
        ILobj_t         *(*mdlobj_to_spec)(ILview_t *view, Agobj_t *model_obj);
 
172
 
 
173
        Agobj_t         *(*spec_to_mdlobj)(ILview_t *view, ILobj_t *spec);
 
174
} ILengine_t;
 
175
 
 
176
/* function dispatch utilities */
 
177
typedef ilbool (*ILnodefn_t)(ILview_t *view, ILnode_t *obj);
 
178
typedef ilbool (*ILedgefn_t)(ILview_t *view, ILedge_t *obj);
 
179
typedef ilbool (*ILhyperfn_t)(ILview_t *view, ILhyper_t *obj);
 
180
typedef ilbool (*ILviewfn_t)(ILview_t *view, ILview_t *obj);
 
181
 
 
182
typedef struct ILfnlist_s {
 
183
        ILnodefn_t      n;
 
184
        ILedgefn_t      e;
 
185
        ILhyperfn_t     m;
 
186
        ILviewfn_t      v;
 
187
} ILfnlist_t;
 
188
 
 
189
ilbool                  ildispatch(ILview_t *view, ILobj_t *spec, ILfnlist_t *f);
 
190
 
 
191
/* Services provided by an incremental layout engine. */
 
192
/* These are stubs that invoke engine functions. */
 
193
/*   ...Maybe these should be deleted. */
 
194
ilbool                  ilopen(ILengine_t *engine, ILview_t *view);
 
195
void                    ilclose(ILview_t *view);
 
196
 
 
197
ilbool                  ilinsert(ILview_t *view, ILobj_t *spec);
 
198
ilbool                  ilmodify(ILview_t *view, ILobj_t *spec);
 
199
ilbool                  iloptimize(ILview_t *view, ILobj_t *spec);      /* deprecated */
 
200
ilbool                  ildelete(ILview_t *view, ILobj_t *spec);
 
201
ilbool                  ilcallback(ILview_t*);
 
202
Agraph_t        *ilmodel(ILview_t *view);       /* special case of ... */
 
203
Agobj_t                 *ilspec_to_mdlobj(ILview_t *view, ILobj_t *spec);
 
204
ILobj_t                 *ilmdlobj_to_spec(ILview_t *view, Agobj_t *obj);
 
205
 
 
206
ILnode_t                *ilnextnode(ILview_t *view, ILnode_t *spec);
 
207
ILedge_t                *ilnextedge(ILview_t *view, ILnode_t *endpoint, ILedge_t *spec);
 
208
 
 
209
#endif  /* AGINCR_H */