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.
20
#define MAXINT INT_MAX
24
#define MAXDOUBLE DBL_MAX
27
#define MAXFLOAT FLT_MAX
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.
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;
44
typedef struct ilshape_s ilshape_t;
45
typedef struct ilcurve_s ilcurve_t;
47
/* Types of diagram objects. */
48
typedef enum {ILNODE=AGNODE, ILEDGE=AGEDGE, ILHYPER, ILVIEW=AGRAPH} ILtag_t;
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.
56
* Client can add its own fields to the base structure.
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.
63
/* generic object/event specifier */
64
typedef struct ILobj_s {
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)
80
/* node event specifier */
81
typedef struct ILnode_s {
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 */
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 */
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 */
109
typedef struct ILhyper_s { /* this is not finished yet */
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 */
117
/* event/callback function */
118
typedef struct ILview_s ILview_t; /* forward decl */
119
typedef ilbool (*ILevf_t)(ILview_t *view, ILobj_t *spec);
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.
126
ILobj_t base; /* defined by clients, immutable. */
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.
133
ilbool enable_immediate_callbacks; /* owned by client, mutable */
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 */
140
/* quanitization unit for coordinates */
141
float resolution; /* owned by clients, immutable. */
143
/* minimum separation between nodes */
144
ildelta separation; /* owned by clients, immutable. */
146
/* desired bounding box, if available, else (0,0) */
149
/* actual bounding box */
152
/* a broad hint about time spent per iteration */
153
float ticks; /* owned by clients, mutable */
155
struct engview_s *pvt; /* owned by engines, immutable */
158
/* Interface to a layout engine. */
159
typedef struct ILengine_s {
160
ilbool (*open)(ILview_t *view);
161
void (*close)(ILview_t *view);
167
/* Issue all pending callbacks. Return TRUE if there were any. */
168
ilbool (*callback)(ILview_t *view);
170
/* Look up spec from model node, edge, or subgraph */
171
ILobj_t *(*mdlobj_to_spec)(ILview_t *view, Agobj_t *model_obj);
173
Agobj_t *(*spec_to_mdlobj)(ILview_t *view, ILobj_t *spec);
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);
182
typedef struct ILfnlist_s {
189
ilbool ildispatch(ILview_t *view, ILobj_t *spec, ILfnlist_t *f);
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);
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);
206
ILnode_t *ilnextnode(ILview_t *view, ILnode_t *spec);
207
ILedge_t *ilnextedge(ILview_t *view, ILnode_t *endpoint, ILedge_t *spec);
209
#endif /* AGINCR_H */