/misc/src/release/graphviz-2.18-1/src/graphviz-2.18/lib/gvc/gvcjob.h

Go to the documentation of this file.
00001 /* $Id: gvcjob.h,v 1.71 2007/12/21 16:42:32 ellson Exp $ $Revision: 1.71 $ */
00002 /* vim:set shiftwidth=4 ts=8: */
00003 
00004 /**********************************************************
00005 *      This software is part of the graphviz package      *
00006 *                http://www.graphviz.org/                 *
00007 *                                                         *
00008 *            Copyright (c) 1994-2004 AT&T Corp.           *
00009 *                and is licensed under the                *
00010 *            Common Public License, Version 1.0           *
00011 *                      by AT&T Corp.                      *
00012 *                                                         *
00013 *        Information and Software Systems Research        *
00014 *              AT&T Research, Florham Park NJ             *
00015 **********************************************************/
00016 
00017 /* Common header used by both clients and plugins */
00018 
00019 #ifndef GVCJOB_H
00020 #define GVCJOB_H
00021 
00022 #ifdef __cplusplus
00023 extern "C" {
00024 #endif
00025 
00026 #include "gvcommon.h"
00027 #include "color.h"
00028 
00029 #define ARRAY_SIZE(A) (sizeof(A)/sizeof(A[0]))
00030 
00031     typedef struct gvdevice_engine_s gvdevice_engine_t;
00032     typedef struct gvformatter_engine_s gvformatter_engine_t;
00033     typedef struct gvrender_engine_s gvrender_engine_t;
00034     typedef struct gvlayout_engine_s gvlayout_engine_t;
00035     typedef struct gvtextlayout_engine_s gvtextlayout_engine_t;
00036     typedef struct gvloadimage_engine_s gvloadimage_engine_t;
00037 
00038     typedef enum { PEN_NONE, PEN_DASHED, PEN_DOTTED, PEN_SOLID } pen_type;
00039     typedef enum { FILL_NONE, FILL_SOLID } fill_type;
00040     typedef enum { FONT_REGULAR, FONT_BOLD, FONT_ITALIC } font_type;
00041 #define PENWIDTH_NORMAL 1.
00042 #define PENWIDTH_BOLD 2.
00043     typedef enum { GVATTR_STRING, GVATTR_BOOL, GVATTR_COLOR } gvattr_t;
00044 
00045 /* The -T output formats listed below are examples only, they are not definitive or inclusive,
00046  other outputs may use the flags now, or in the future 
00047 
00048                    Default emit order is breadth first graph walk order 
00049  EMIT_SORTED                    emits nodes before edges                
00050  EMIT_COLORS                    emits colors before nodes or edge -Tfig 
00051  EMIT_CLUSTERS_LAST             emits cluster after nodes and edges     
00052  EMIT_PREORDER                  emit in preorder traversal ???          
00053  EMIT_EDGE_SORTED               emits edges before nodes                
00054 
00055  GVDEVICE_DOES_PAGES            provides pagination support -Tps        
00056  GVDEVICE_DOES_LAYERS           provides support for layers -Tps        
00057  GVDEVICE_EVENTS                supports mouse events -Tgtk, -Txlib     
00058  GVDEVICE_DOES_TRUECOLOR        supports alph channel -Tpng, -Tgtk, -Txlib 
00059  GVDEVICE_BINARY_FORMAT         Suppresses \r\n substitution for linends 
00060  GVDEVICE_COMPRESSED_FORMAT     controls libz compression               
00061  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)
00062 
00063  GVRENDER_Y_GOES_DOWN           device origin top left, y goes down, otherwise
00064                                 device origin lower left, y goes up     
00065  GVRENDER_DOES_TRANSFORM        device uses scale, translate, rotate to do its own
00066                                 coordinate transformations, otherwise coordinates 
00067                                 are pre-transformed                     
00068  GVRENDER_DOES_ARROWS           renderer has its own idea of arrow shapes (deprecated) 
00069  GVRENDER_DOES_LABELS           basically, maps don't need labels       
00070  GVRENDER_DOES_MAPS             renderer encodes mapping information for mouse events -Tcmapx -Tsvg 
00071  GVRENDER_DOES_MAP_RECTANGLE    supports a 2 coord rectngle optimization 
00072  GVRENDER_DOES_MAP_CIRCLE       supports a 1 coord + radius circle optimization 
00073  GVRENDER_DOES_MAP_POLYGON      supports polygons (basically, -Tsvg uses anchors, so doesn't need to support any map shapes) 
00074  GVRENDER_DOES_MAP_ELLIPSE      supports a 2 coord ellipse optimization 
00075  GVRENDER_DOES_MAP_BSPLINE      supports mapping of splines             
00076  GVRENDER_DOES_TOOLTIPS         can represent tooltip info -Tcmapx, -Tsvg               
00077  GVRENDER_DOES_TARGETS          can represent target info (open link in a new tab or window) 
00078  GVRENDER_DOES_Z                render support 2.5D representation -Tvrml 
00079  GVRENDER_NO_BG                 don't paint white background, assumes white paper -Tps 
00080  LAYOUT_NOT_REQUIRED            don't perform layout -Tcanon            
00081  OUTPUT_NOT_REQUIRED            don't use gvdevice for output (basically when agwrite() used instead) -Tcanon, -Txdot 
00082  */
00083 
00084 
00085 #define EMIT_SORTED (1<<0)
00086 #define EMIT_COLORS (1<<1)
00087 #define EMIT_CLUSTERS_LAST (1<<2)
00088 #define EMIT_PREORDER (1<<3)
00089 #define EMIT_EDGE_SORTED (1<<4)
00090 #define GVDEVICE_DOES_PAGES (1<<5)
00091 #define GVDEVICE_DOES_LAYERS (1<<6)
00092 #define GVDEVICE_EVENTS (1<<7)
00093 #define GVDEVICE_DOES_TRUECOLOR (1<<8)
00094 #define GVDEVICE_BINARY_FORMAT (1<<9)
00095 #define GVDEVICE_COMPRESSED_FORMAT (1<<10)
00096 #define GVDEVICE_NO_WRITER (1<<11)
00097 #define GVRENDER_Y_GOES_DOWN (1<<12)
00098 #define GVRENDER_DOES_TRANSFORM (1<<13)
00099 #define GVRENDER_DOES_ARROWS (1<<14)
00100 #define GVRENDER_DOES_LABELS (1<<15)
00101 #define GVRENDER_DOES_MAPS (1<<16)
00102 #define GVRENDER_DOES_MAP_RECTANGLE (1<<17)
00103 #define GVRENDER_DOES_MAP_CIRCLE (1<<18)
00104 #define GVRENDER_DOES_MAP_POLYGON (1<<19)
00105 #define GVRENDER_DOES_MAP_ELLIPSE (1<<20)
00106 #define GVRENDER_DOES_MAP_BSPLINE (1<<21)
00107 #define GVRENDER_DOES_TOOLTIPS (1<<22)
00108 #define GVRENDER_DOES_TARGETS (1<<23)
00109 #define GVRENDER_DOES_Z (1<<24)
00110 #define GVRENDER_NO_BG (1<<25)
00111 #define LAYOUT_NOT_REQUIRED (1<<26)
00112 #define OUTPUT_NOT_REQUIRED (1<<27)
00113 
00114     typedef struct {
00115         int flags;
00116         double default_pad;     /* graph units */
00117         char **knowncolors;
00118         int sz_knowncolors;
00119         color_type_t color_type;
00120     } gvrender_features_t;
00121 
00122     typedef struct {
00123         int flags;
00124         pointf default_margin;  /* left/right, top/bottom - points */
00125         pointf default_pagesize;/* default page width, height - points */
00126         pointf default_dpi;
00127     } gvdevice_features_t;
00128 
00129 #define LAYOUT_USES_RANKDIR (1<<0)
00130 
00131     typedef struct gvplugin_active_device_s {
00132         gvdevice_engine_t *engine;
00133         int id;
00134         gvdevice_features_t *features;
00135         char *type;
00136     } gvplugin_active_device_t;
00137 
00138     typedef struct gvplugin_active_render_s {
00139         gvrender_engine_t *engine;
00140         int id;
00141         gvrender_features_t *features;
00142         char *type;
00143     } gvplugin_active_render_t;
00144 
00145     typedef struct gvplugin_active_loadimage_t {
00146         gvloadimage_engine_t *engine;
00147         int id;
00148         char *type;
00149     } gvplugin_active_loadimage_t;
00150 
00151     typedef struct gv_argvlist_s {
00152         char **argv;
00153         int argc;
00154         int alloc;
00155     } gv_argvlist_t;
00156 
00157     typedef struct gvdevice_callbacks_s {
00158         void (*refresh) (GVJ_t * job);
00159         void (*button_press) (GVJ_t * job, int button, pointf pointer);
00160         void (*button_release) (GVJ_t * job, int button, pointf pointer);
00161         void (*motion) (GVJ_t * job, pointf pointer);
00162         void (*modify) (GVJ_t * job, char *name, char *value);
00163         void (*del) (GVJ_t * job);  /* can't use "delete" 'cos C++ stole it */
00164         void (*read) (GVJ_t * job, char *filename, char *layout);
00165         void (*layout) (GVJ_t * job, char *layout);
00166         void (*render) (GVJ_t * job, char *format, char *filename);
00167     } gvdevice_callbacks_t;
00168 
00169     typedef int (*gvevent_key_callback_t) (GVJ_t * job);
00170 
00171     typedef struct gvevent_key_binding_s {
00172         char *keystring;
00173         gvevent_key_callback_t callback;
00174     } gvevent_key_binding_t;
00175 
00176     typedef enum {MAP_RECTANGLE, MAP_CIRCLE, MAP_POLYGON, } map_shape_t;
00177 
00178     typedef enum {ROOTGRAPH_OBJTYPE, CLUSTER_OBJTYPE, NODE_OBJTYPE, EDGE_OBJTYPE} obj_type;
00179 
00180     /* See comment in gvrender_core_dot.c */
00181     typedef enum {
00182         EMIT_GDRAW, EMIT_CDRAW, EMIT_TDRAW, EMIT_HDRAW, 
00183         EMIT_GLABEL, EMIT_CLABEL, EMIT_TLABEL, EMIT_HLABEL,
00184         EMIT_NDRAW, EMIT_EDRAW, EMIT_NLABEL, EMIT_ELABEL,  
00185     } emit_state_t;
00186 
00187     typedef struct obj_state_s obj_state_t;
00188 
00189     struct obj_state_s {
00190         obj_state_t *parent;
00191 
00192         obj_type type;
00193         union {
00194             graph_t *g;
00195             graph_t *sg;  
00196             node_t *n;
00197             edge_t *e;
00198         } u;
00199 
00200         emit_state_t emit_state; 
00201 
00202         gvcolor_t pencolor, fillcolor;
00203         pen_type pen;
00204         fill_type fill;
00205         double penwidth;
00206         char **rawstyle;
00207 
00208         double z, tail_z, head_z;   /* z depths for 2.5D renderers such as vrml */
00209 
00210         /* fully substituted text strings */
00211         char *label;
00212         char *taillabel;
00213         char *headlabel; 
00214 
00215         char *url;              /* if GVRENDER_DOES_MAPS */
00216         char *labelurl;
00217         char *tailurl;
00218         char *headurl; 
00219 
00220         char *tooltip;          /* if GVRENDER_DOES_TOOLTIPS */
00221         char *labeltooltip;
00222         char *tailtooltip;
00223         char *headtooltip; 
00224 
00225         char *target;           /* if GVRENDER_DOES_TARGETS */
00226         char *labeltarget;
00227         char *tailtarget;
00228         char *headtarget; 
00229 
00230         int explicit_tooltip:1;
00231         int explicit_tailtooltip:1;
00232         int explicit_headtooltip:1;
00233         int explicit_labeltooltip:1;
00234         int explicit_tailtarget:1;
00235         int explicit_headtarget:1;
00236         int explicit_edgetarget:1;
00237         int explicit_tailurl:1;
00238         int explicit_headurl:1;
00239 
00240         /* primary mapped region - node shape, edge labels */
00241         map_shape_t url_map_shape; 
00242         int url_map_n;                  /* number of points for url map if GVRENDER_DOES_MAPS */
00243         pointf *url_map_p;
00244 
00245         /* additonal mapped regions for edges */
00246         int url_bsplinemap_poly_n;      /* number of polygons in url bspline map
00247                                          if GVRENDER_DOES_MAPS && GVRENDER_DOES_MAP_BSPLINES */
00248         int *url_bsplinemap_n;          /* array of url_bsplinemap_poly_n ints 
00249                                          of number of points in each polygon */
00250         pointf *url_bsplinemap_p;       /* all the polygon points */
00251 
00252         int tailendurl_map_n;           /* tail end intersection with node */
00253         pointf *tailendurl_map_p;
00254 
00255         int headendurl_map_n;           /* head end intersection with node */
00256         pointf *headendurl_map_p;
00257     };
00258 
00259 /* Note on units:
00260  *     points  - a physical distance (1/72 inch) unaffected by zoom or dpi.
00261  *     graph units - related to physical distance by zoom.  Equals points at zoom=1
00262  *     device units - related to physical distance in points by dpi/72
00263  */
00264 
00265     struct GVJ_s {
00266         GVC_t *gvc;             /* parent gvc */
00267         GVJ_t *next;            /* linked list of jobs */
00268         GVJ_t *next_active;     /* linked list of active jobs (e.g. multiple windows) */
00269 
00270         GVCOMMON_t *common;
00271 
00272         obj_state_t *obj;       /* objects can be nested (at least clusters can)
00273                                         so keep object state on a stack */
00274         char *input_filename;
00275         int graph_index;
00276 
00277         char *layout_type;
00278 
00279         char *output_filename;
00280         FILE *output_file;
00281         char *output_data;
00282         unsigned int output_data_allocated;
00283         unsigned int output_data_position;
00284 
00285         char *output_langname;
00286         int output_lang;
00287 
00288         gvplugin_active_render_t render;
00289         gvplugin_active_device_t device;
00290         gvplugin_active_loadimage_t loadimage;
00291         gvdevice_callbacks_t *callbacks;
00292         pointf device_dpi;
00293         boolean device_sets_dpi;
00294 
00295         void *display;
00296         int screen;
00297 
00298         void *context;          /* gd or cairo surface */
00299         boolean external_context;       /* context belongs to caller */
00300         unsigned char *imagedata; /* location of imagedata */
00301 
00302         int flags;              /* emit_graph flags */
00303 
00304         int numLayers;          /* number of layers */
00305         int layerNum;           /* current layer - 1 based*/
00306 
00307         point   pagesArraySize; /* 2D size of page array */
00308         point   pagesArrayFirst;/* 2D starting corner in */
00309         point   pagesArrayMajor;/* 2D major increment */
00310         point   pagesArrayMinor;/* 2D minor increment */
00311         point   pagesArrayElem; /* 2D coord of current page - 0,0 based */
00312         int     numPages;       /* number of pages */
00313 
00314         boxf    bb;             /* graph bb with padding - graph units */
00315         pointf  pad;            /* padding around bb - graph units */
00316         boxf    clip;           /* clip region in graph units */
00317         boxf    pageBox;        /* current page in graph units */
00318         pointf  pageOffset;     /* offset for current page in graph units */
00319         pointf  pageSize;       /* page size in graph units */
00320         pointf  focus;          /* viewport focus - graph units */
00321 
00322         double  zoom;           /* viewport zoom factor (points per graph unit) */
00323         int     rotation;       /* viewport rotation (degrees)  0=portrait, 90=landscape */
00324 
00325         pointf  view;           /* viewport size - points */
00326         boxf    canvasBox;      /* viewport area - points */
00327         pointf  margin;         /* job-specific margin - points */
00328 
00329         pointf  dpi;            /* device resolution device-units-per-inch */
00330 
00331         unsigned int width;     /* device width - device units */
00332         unsigned int height;    /* device height - device units */
00333         box     pageBoundingBox;/* rotated boundingBox - device units */
00334         box     boundingBox;    /* cumulative boundingBox over all pages - device units */
00335 
00336         pointf  scale;          /* composite device to graph units (zoom and dpi) */
00337         pointf  translation;    /* composite translation */
00338         pointf  devscale;       /* composite device to points: dpi, y_goes_down */
00339 
00340         boolean fit_mode,
00341                 needs_refresh,
00342                 click,
00343                 has_grown,
00344                 has_been_rendered;
00345 
00346         unsigned char button;   /* active button */
00347         pointf pointer;         /* pointer position in device units */
00348         pointf oldpointer;      /* old pointer position in device units */
00349 
00350         void *current_obj;      /* graph object that pointer is in currently */
00351 
00352         void *selected_obj;      /* graph object that has been selected */
00353                                         /* (e.g. button 1 clicked on current obj) */
00354         char *active_tooltip;           /* tooltip of active object - or NULL */
00355         char *selected_href;            /* href of selected object - or NULL */
00356         gv_argvlist_t selected_obj_type_name; /* (e.g. "edge" "node3" "e" "->" "node5" "") */
00357         gv_argvlist_t selected_obj_attributes; /* attribute triplets: name, value, type */
00358                                 /* e.g. "color", "red", GVATTR_COLOR,
00359                                         "style", "filled", GVATTR_BOOL, */
00360 
00361         void *window;           /* display-specific data for gvrender plugin */
00362 
00363         /* keybindings for keyboard events */
00364         gvevent_key_binding_t *keybindings;
00365         int numkeys;
00366         void *keycodes;
00367 
00368 /* Must be last as separately compiled plugins are not compiled with WITH_CODEGENS */
00369 #ifdef WITH_CODEGENS
00370         codegen_t *codegen;     /* current  codegen */
00371 #endif
00372     };
00373 
00374 #ifdef __cplusplus
00375 }
00376 #endif
00377 #endif                          /* GVCJOB_H */

Generated on Mon Mar 31 19:03:26 2008 for Graphviz by  doxygen 1.5.1