Graphviz  2.41.20171026.1811
gvcjob.h
Go to the documentation of this file.
1 /* $Id$ $Revision$ */
2 /* vim:set shiftwidth=4 ts=8: */
3 
4 /*************************************************************************
5  * Copyright (c) 2011 AT&T Intellectual Property
6  * All rights reserved. This program and the accompanying materials
7  * are made available under the terms of the Eclipse Public License v1.0
8  * which accompanies this distribution, and is available at
9  * http://www.eclipse.org/legal/epl-v10.html
10  *
11  * Contributors: See CVS logs. Details at http://www.graphviz.org/
12  *************************************************************************/
13 
14 /* Common header used by both clients and plugins */
15 
16 #ifndef GVCJOB_H
17 #define GVCJOB_H
18 
19 #ifdef __cplusplus
20 extern "C" {
21 #endif
22 
23 #include "gvcommon.h"
24 #include "color.h"
25 
26 #define ARRAY_SIZE(A) (sizeof(A)/sizeof(A[0]))
27 
29  typedef struct gvformatter_engine_s gvformatter_engine_t;
34 
38  typedef enum { LABEL_PLAIN, LABEL_HTML } label_type;
39 
40 #define PENWIDTH_NORMAL 1.
41 #define PENWIDTH_BOLD 2.
43 
44 /* The -T output formats listed below are examples only, they are not definitive or inclusive,
45  other outputs may use the flags now, or in the future
46 
47  Default emit order is breadth first graph walk order
48  EMIT_SORTED emits nodes before edges
49  EMIT_COLORS emits colors before nodes or edge -Tfig
50  EMIT_CLUSTERS_LAST emits cluster after nodes and edges
51  EMIT_PREORDER emit in preorder traversal ???
52  EMIT_EDGE_SORTED emits edges before nodes
53 
54  GVDEVICE_DOES_PAGES provides pagination support -Tps
55  GVDEVICE_DOES_LAYERS provides support for layers -Tps
56  GVDEVICE_EVENTS supports mouse events -Tgtk, -Txlib
57  GVDEVICE_DOES_TRUECOLOR supports alpha channel -Tpng, -Tgtk, -Txlib
58  GVDEVICE_BINARY_FORMAT Suppresses \r\n substitution for linends
59  GVDEVICE_COMPRESSED_FORMAT controls libz compression
60  GVDEVICE_NO_WRITER used when gvdevice is not used because device uses its own writer, -Tming, devil outputs (FIXME seems to overlap OUTPUT_NOT_REQUIRED)
61 
62  GVRENDER_Y_GOES_DOWN device origin top left, y goes down, otherwise
63  device origin lower left, y goes up
64  GVRENDER_DOES_TRANSFORM device uses scale, translate, rotate to do its own
65  coordinate transformations, otherwise coordinates
66  are pre-transformed
67  GVRENDER_DOES_ARROWS renderer has its own idea of arrow shapes (deprecated)
68  GVRENDER_DOES_LABELS basically, maps don't need labels
69  GVRENDER_DOES_MAPS renderer encodes mapping information for mouse events -Tcmapx -Tsvg
70  GVRENDER_DOES_MAP_RECTANGLE supports a 2 coord rectngle optimization
71  GVRENDER_DOES_MAP_CIRCLE supports a 1 coord + radius circle optimization
72  GVRENDER_DOES_MAP_POLYGON supports polygons (basically, -Tsvg uses anchors, so doesn't need to support any map shapes)
73  GVRENDER_DOES_MAP_ELLIPSE supports a 2 coord ellipse optimization
74  GVRENDER_DOES_MAP_BSPLINE supports mapping of splines
75  GVRENDER_DOES_TOOLTIPS can represent tooltip info -Tcmapx, -Tsvg
76  GVRENDER_DOES_TARGETS can represent target info (open link in a new tab or window)
77  GVRENDER_DOES_Z render support 2.5D representation -Tvrml
78  GVRENDER_NO_WHITE_BG don't paint white background, assumes white paper -Tps
79  LAYOUT_NOT_REQUIRED don't perform layout -Tcanon
80  OUTPUT_NOT_REQUIRED don't use gvdevice for output (basically when agwrite() used instead) -Tcanon, -Txdot
81  */
82 
83 
84 #define EMIT_SORTED (1<<0)
85 #define EMIT_COLORS (1<<1)
86 #define EMIT_CLUSTERS_LAST (1<<2)
87 #define EMIT_PREORDER (1<<3)
88 #define EMIT_EDGE_SORTED (1<<4)
89 #define GVDEVICE_DOES_PAGES (1<<5)
90 #define GVDEVICE_DOES_LAYERS (1<<6)
91 #define GVDEVICE_EVENTS (1<<7)
92 #define GVDEVICE_DOES_TRUECOLOR (1<<8)
93 #define GVDEVICE_BINARY_FORMAT (1<<9)
94 #define GVDEVICE_COMPRESSED_FORMAT (1<<10)
95 #define GVDEVICE_NO_WRITER (1<<11)
96 #define GVRENDER_Y_GOES_DOWN (1<<12)
97 #define GVRENDER_DOES_TRANSFORM (1<<13)
98 #define GVRENDER_DOES_ARROWS (1<<14)
99 #define GVRENDER_DOES_LABELS (1<<15)
100 #define GVRENDER_DOES_MAPS (1<<16)
101 #define GVRENDER_DOES_MAP_RECTANGLE (1<<17)
102 #define GVRENDER_DOES_MAP_CIRCLE (1<<18)
103 #define GVRENDER_DOES_MAP_POLYGON (1<<19)
104 #define GVRENDER_DOES_MAP_ELLIPSE (1<<20)
105 #define GVRENDER_DOES_MAP_BSPLINE (1<<21)
106 #define GVRENDER_DOES_TOOLTIPS (1<<22)
107 #define GVRENDER_DOES_TARGETS (1<<23)
108 #define GVRENDER_DOES_Z (1<<24)
109 #define GVRENDER_NO_WHITE_BG (1<<25)
110 #define LAYOUT_NOT_REQUIRED (1<<26)
111 #define OUTPUT_NOT_REQUIRED (1<<27)
112 
113  typedef struct {
114  int flags;
115  double default_pad; /* graph units */
116  char **knowncolors;
120 
121  typedef struct {
122  int flags;
123  pointf default_margin; /* left/right, top/bottom - points */
124  pointf default_pagesize;/* default page width, height - points */
127 
128 #define LAYOUT_USES_RANKDIR (1<<0)
129 
130  typedef struct gvplugin_active_device_s {
132  int id;
134  const char *type;
136 
137  typedef struct gvplugin_active_render_s {
139  int id;
141  const char *type;
143 
146  int id;
147  const char *type;
149 
150  typedef struct gv_argvlist_s {
151  char **argv;
152  int argc;
153  int alloc;
154  } gv_argvlist_t;
155 
156  typedef struct gvdevice_callbacks_s {
157  void (*refresh) (GVJ_t * job);
158  void (*button_press) (GVJ_t * job, int button, pointf pointer);
159  void (*button_release) (GVJ_t * job, int button, pointf pointer);
160  void (*motion) (GVJ_t * job, pointf pointer);
161  void (*modify) (GVJ_t * job, const char *name, const char *value);
162  void (*del) (GVJ_t * job); /* can't use "delete" 'cos C++ stole it */
163  void (*read) (GVJ_t * job, const char *filename, const char *layout);
164  void (*layout) (GVJ_t * job, const char *layout);
165  void (*render) (GVJ_t * job, const char *format, const char *filename);
167 
168  typedef int (*gvevent_key_callback_t) (GVJ_t * job);
169 
170  typedef struct gvevent_key_binding_s {
171  char *keystring;
174 
176 
178 
179  /* If this enum is changed, the implementation of xbuf and xbufs in
180  * gvrender_core_dot.c will probably need to be changed.
181  */
182  typedef enum {
186  } emit_state_t;
187 
188  typedef struct obj_state_s obj_state_t;
189 
190  struct obj_state_s {
192 
194  union {
199  } u;
200 
202 
208  double penwidth;
209  char **rawstyle;
210 
211  double z, tail_z, head_z; /* z depths for 2.5D renderers such as vrml */
212 
213  /* fully substituted text strings */
214  char *label;
215  char *xlabel;
216  char *taillabel;
217  char *headlabel;
218 
219  char *url; /* if GVRENDER_DOES_MAPS */
220  char *id;
221  char *labelurl;
222  char *tailurl;
223  char *headurl;
224 
225  char *tooltip; /* if GVRENDER_DOES_TOOLTIPS */
227  char *tailtooltip;
228  char *headtooltip;
229 
230  char *target; /* if GVRENDER_DOES_TARGETS */
231  char *labeltarget;
232  char *tailtarget;
233  char *headtarget;
234 
245 
246  /* primary mapped region - node shape, edge labels */
248  int url_map_n; /* number of points for url map if GVRENDER_DOES_MAPS */
250 
251  /* additional mapped regions for edges */
252  int url_bsplinemap_poly_n; /* number of polygons in url bspline map
253  if GVRENDER_DOES_MAPS && GVRENDER_DOES_MAP_BSPLINES */
254  int *url_bsplinemap_n; /* array of url_bsplinemap_poly_n ints
255  of number of points in each polygon */
256  pointf *url_bsplinemap_p; /* all the polygon points */
257 
258  int tailendurl_map_n; /* tail end intersection with node */
260 
261  int headendurl_map_n; /* head end intersection with node */
263  };
264 
265 /* Note on units:
266  * points - a physical distance (1/72 inch) unaffected by zoom or dpi.
267  * graph units - related to physical distance by zoom. Equals points at zoom=1
268  * device units - related to physical distance in points by dpi/72
269  */
270 
271  struct GVJ_s {
272  GVC_t *gvc; /* parent gvc */
273  GVJ_t *next; /* linked list of jobs */
274  GVJ_t *next_active; /* linked list of active jobs (e.g. multiple windows) */
275 
277 
278  obj_state_t *obj; /* objects can be nested (at least clusters can)
279  so keep object state on a stack */
282 
283  const char *layout_type;
284 
285  const char *output_filename;
286  FILE *output_file;
287  char *output_data;
288  unsigned int output_data_allocated;
289  unsigned int output_data_position;
290 
291  const char *output_langname;
293 
300 
301  void *display;
302  int screen;
303 
304  void *context; /* gd or cairo surface */
305  boolean external_context; /* context belongs to caller */
306  char *imagedata; /* location of imagedata */
307 
308  int flags; /* emit_graph flags */
309 
310  int numLayers; /* number of layers */
311  int layerNum; /* current layer - 1 based*/
312 
313  point pagesArraySize; /* 2D size of page array */
314  point pagesArrayFirst;/* 2D starting corner in */
315  point pagesArrayMajor;/* 2D major increment */
316  point pagesArrayMinor;/* 2D minor increment */
317  point pagesArrayElem; /* 2D coord of current page - 0,0 based */
318  int numPages; /* number of pages */
319 
320  boxf bb; /* graph bb with padding - graph units */
321  pointf pad; /* padding around bb - graph units */
322  boxf clip; /* clip region in graph units */
323  boxf pageBox; /* current page in graph units */
324  pointf pageSize; /* page size in graph units */
325  pointf focus; /* viewport focus - graph units */
326 
327  double zoom; /* viewport zoom factor (points per graph unit) */
328  int rotation; /* viewport rotation (degrees) 0=portrait, 90=landscape */
329 
330  pointf view; /* viewport size - points */
331  boxf canvasBox; /* viewport area - points */
332  pointf margin; /* job-specific margin - points */
333 
334  pointf dpi; /* device resolution device-units-per-inch */
335 
336  unsigned int width; /* device width - device units */
337  unsigned int height; /* device height - device units */
338  box pageBoundingBox;/* rotated boundingBox - device units */
339  box boundingBox; /* cumulative boundingBox over all pages - device units */
340 
341  pointf scale; /* composite device to graph units (zoom and dpi) */
342  pointf translation; /* composite translation */
343  pointf devscale; /* composite device to points: dpi, y_goes_down */
344 
345  boolean fit_mode,
347  click,
348  has_grown,
350 
351  unsigned char button; /* active button */
352  pointf pointer; /* pointer position in device units */
353  pointf oldpointer; /* old pointer position in device units */
354 
355  void *current_obj; /* graph object that pointer is in currently */
356 
357  void *selected_obj; /* graph object that has been selected */
358  /* (e.g. button 1 clicked on current obj) */
359  char *active_tooltip; /* tooltip of active object - or NULL */
360  char *selected_href; /* href of selected object - or NULL */
361  gv_argvlist_t selected_obj_type_name; /* (e.g. "edge" "node3" "e" "->" "node5" "") */
362  gv_argvlist_t selected_obj_attributes; /* attribute triplets: name, value, type */
363  /* e.g. "color", "red", GVATTR_COLOR,
364  "style", "filled", GVATTR_BOOL, */
365 
366  void *window; /* display-specific data for gvrender plugin */
367 
368  /* keybindings for keyboard events */
370  int numkeys;
371  void *keycodes;
372  };
373 
374 #ifdef __cplusplus
375 }
376 #endif
377 #endif /* GVCJOB_H */
pointf device_dpi
Definition: gvcjob.h:298
int explicit_tailtarget
Definition: gvcjob.h:239
double default_pad
Definition: gvcjob.h:115
int explicit_headurl
Definition: gvcjob.h:243
pointf * tailendurl_map_p
Definition: gvcjob.h:259
char ** rawstyle
Definition: gvcjob.h:209
gvcolor_t stopcolor
Definition: gvcjob.h:203
void(* button_press)(GVJ_t *job, int button, pointf pointer)
Definition: gvcjob.h:158
pointf margin
Definition: gvcjob.h:332
point pagesArrayFirst
Definition: gvcjob.h:314
int rotation
Definition: gvcjob.h:328
box boundingBox
Definition: gvcjob.h:339
struct gvplugin_active_render_s gvplugin_active_render_t
char * imagedata
Definition: gvcjob.h:306
pointf default_margin
Definition: gvcjob.h:123
char * labeltooltip
Definition: gvcjob.h:226
int(* gvevent_key_callback_t)(GVJ_t *job)
Definition: gvcjob.h:168
int url_map_n
Definition: gvcjob.h:248
void * current_obj
Definition: gvcjob.h:355
unsigned int output_data_allocated
Definition: gvcjob.h:288
pointf pointer
Definition: gvcjob.h:352
int explicit_headtarget
Definition: gvcjob.h:240
fill_type
Definition: gvcjob.h:36
emit_state_t
Definition: gvcjob.h:182
void * context
Definition: gvcjob.h:304
void * display
Definition: gvcjob.h:301
char * headlabel
Definition: gvcjob.h:217
char * xlabel
Definition: gvcjob.h:215
char * tailtooltip
Definition: gvcjob.h:227
void(* refresh)(GVJ_t *job)
Definition: gvcjob.h:157
void * selected_obj
Definition: gvcjob.h:357
pen_type pen
Definition: gvcjob.h:206
int numLayers
Definition: gvcjob.h:310
point pagesArraySize
Definition: gvcjob.h:313
int explicit_edgetarget
Definition: gvcjob.h:241
Definition: geom.h:28
double head_z
Definition: gvcjob.h:211
char * input_filename
Definition: gvcjob.h:280
boolean has_grown
Definition: gvcjob.h:345
unsigned int width
Definition: gvcjob.h:336
pointf oldpointer
Definition: gvcjob.h:353
struct gvdevice_callbacks_s gvdevice_callbacks_t
void * keycodes
Definition: gvcjob.h:371
gvplugin_active_loadimage_t loadimage
Definition: gvcjob.h:296
char * label
Definition: gvcjob.h:214
Definition: color.h:34
const char * output_filename
Definition: gvcjob.h:285
int flags
Definition: gvcjob.h:308
int explicit_tailtooltip
Definition: gvcjob.h:236
gvcolor_t pencolor
Definition: gvcjob.h:203
Definition: gvcjob.h:271
char * labeltarget
Definition: gvcjob.h:231
int headendurl_map_n
Definition: gvcjob.h:261
obj_type
Definition: gvcjob.h:177
int explicit_tailurl
Definition: gvcjob.h:242
boxf pageBox
Definition: gvcjob.h:323
obj_state_t * obj
Definition: gvcjob.h:278
gvplugin_active_device_t device
Definition: gvcjob.h:295
boxf clip
Definition: gvcjob.h:322
GVJ_t * next
Definition: gvcjob.h:273
pointf devscale
Definition: gvcjob.h:343
void(* button_release)(GVJ_t *job, int button, pointf pointer)
Definition: gvcjob.h:159
gvloadimage_engine_t * engine
Definition: gvcjob.h:145
pointf dpi
Definition: gvcjob.h:334
box pageBoundingBox
Definition: gvcjob.h:338
char * output_data
Definition: gvcjob.h:287
char * active_tooltip
Definition: gvcjob.h:359
gv_argvlist_t selected_obj_type_name
Definition: gvcjob.h:361
char * selected_href
Definition: gvcjob.h:360
unsigned int output_data_position
Definition: gvcjob.h:289
char * tooltip
Definition: gvcjob.h:225
int
Definition: grammar.c:1264
int graph_index
Definition: gvcjob.h:281
point pagesArrayMajor
Definition: gvcjob.h:315
char * tailtarget
Definition: gvcjob.h:232
pointf pad
Definition: gvcjob.h:321
gvplugin_active_render_t render
Definition: gvcjob.h:294
gvrender_features_t * features
Definition: gvcjob.h:140
int screen
Definition: gvcjob.h:302
color_type_t color_type
Definition: gvcjob.h:118
void * window
Definition: gvcjob.h:366
boxf canvasBox
Definition: gvcjob.h:331
gvattr_t
Definition: gvcjob.h:42
void(* layout)(GVJ_t *job, const char *layout)
Definition: gvcjob.h:164
Definition: gvcint.h:70
char * labelurl
Definition: gvcjob.h:221
pointf * url_map_p
Definition: gvcjob.h:249
pointf focus
Definition: gvcjob.h:325
obj_type type
Definition: gvcjob.h:193
GVJ_t * next_active
Definition: gvcjob.h:274
char * url
Definition: gvcjob.h:219
int * url_bsplinemap_n
Definition: gvcjob.h:254
pointf scale
Definition: gvcjob.h:341
pointf * url_bsplinemap_p
Definition: gvcjob.h:256
GVCOMMON_t * common
Definition: gvcjob.h:276
point pagesArrayElem
Definition: gvcjob.h:317
pointf view
Definition: gvcjob.h:330
struct gvplugin_active_device_s gvplugin_active_device_t
boolean click
Definition: gvcjob.h:345
GVC_t * gvc
Definition: gvcjob.h:272
label_type
Definition: gvcjob.h:38
int gradient_angle
Definition: gvcjob.h:204
char ** knowncolors
Definition: gvcjob.h:116
boxf bb
Definition: gvcjob.h:320
color_type_t
Definition: color.h:30
emit_state_t emit_state
Definition: gvcjob.h:201
const char * type
Definition: gvcjob.h:141
graph_t * g
Definition: gvcjob.h:195
pointf pageSize
Definition: gvcjob.h:324
unsigned char button
Definition: gvcjob.h:351
int layerNum
Definition: gvcjob.h:311
char * headtarget
Definition: gvcjob.h:233
gvevent_key_binding_t * keybindings
Definition: gvcjob.h:369
void(* render)(GVJ_t *job, const char *format, const char *filename)
Definition: gvcjob.h:165
struct gvformatter_engine_s gvformatter_engine_t
Definition: gvcjob.h:29
const char * layout_type
Definition: gvcjob.h:283
void(* del)(GVJ_t *job)
Definition: gvcjob.h:162
struct gvplugin_active_loadimage_t gvplugin_active_loadimage_t
float gradient_frac
Definition: gvcjob.h:205
gv_argvlist_t selected_obj_attributes
Definition: gvcjob.h:362
pointf translation
Definition: gvcjob.h:342
graph_t * sg
Definition: gvcjob.h:196
font_type
Definition: gvcjob.h:37
Definition: geom.h:26
boolean device_sets_dpi
Definition: gvcjob.h:299
boolean external_context
Definition: gvcjob.h:305
void(* read)(GVJ_t *job, const char *filename, const char *layout)
Definition: gvcjob.h:163
point pagesArrayMinor
Definition: gvcjob.h:316
gvevent_key_callback_t callback
Definition: gvcjob.h:172
boolean has_been_rendered
Definition: gvcjob.h:345
obj_state_t * parent
Definition: gvcjob.h:191
int numPages
Definition: gvcjob.h:318
boolean needs_refresh
Definition: gvcjob.h:345
int numkeys
Definition: gvcjob.h:370
pen_type
Definition: gvcjob.h:35
pointf * headendurl_map_p
Definition: gvcjob.h:262
struct gvevent_key_binding_s gvevent_key_binding_t
int url_bsplinemap_poly_n
Definition: gvcjob.h:252
int explicit_labeltooltip
Definition: gvcjob.h:238
union obj_state_s::@23 u
boolean fit_mode
Definition: gvcjob.h:345
char * target
Definition: gvcjob.h:230
int tailendurl_map_n
Definition: gvcjob.h:258
pointf default_dpi
Definition: gvcjob.h:125
map_shape_t
Definition: gvcjob.h:175
char * tailurl
Definition: gvcjob.h:222
edge_t * e
Definition: gvcjob.h:198
void(* motion)(GVJ_t *job, pointf pointer)
Definition: gvcjob.h:160
int explicit_headtooltip
Definition: gvcjob.h:237
double z
Definition: gvcjob.h:211
char * id
Definition: gvcjob.h:220
gvcolor_t fillcolor
Definition: gvcjob.h:203
node_t * n
Definition: gvcjob.h:197
int output_lang
Definition: gvcjob.h:292
double penwidth
Definition: gvcjob.h:208
char * headtooltip
Definition: gvcjob.h:228
int explicit_tooltip
Definition: gvcjob.h:235
map_shape_t url_map_shape
Definition: gvcjob.h:247
fill_type fill
Definition: gvcjob.h:207
gvdevice_engine_t * engine
Definition: gvcjob.h:131
FILE * output_file
Definition: gvcjob.h:286
struct gv_argvlist_s gv_argvlist_t
double zoom
Definition: gvcjob.h:327
const char * type
Definition: gvcjob.h:134
double tail_z
Definition: gvcjob.h:211
char * taillabel
Definition: gvcjob.h:216
pointf default_pagesize
Definition: gvcjob.h:124
Definition: geom.h:35
unsigned int height
Definition: gvcjob.h:337
int labeledgealigned
Definition: gvcjob.h:244
gvdevice_callbacks_t * callbacks
Definition: gvcjob.h:297
const char * output_langname
Definition: gvcjob.h:291
char ** argv
Definition: gvcjob.h:151
char * headurl
Definition: gvcjob.h:223
Definition: geom.h:33
gvdevice_features_t * features
Definition: gvcjob.h:133
gvrender_engine_t * engine
Definition: gvcjob.h:138
void(* modify)(GVJ_t *job, const char *name, const char *value)
Definition: gvcjob.h:161