Daniel@0: /* $Id: gvcjob.h,v 1.82 2009/07/08 15:14:20 ellson Exp $ $Revision: 1.82 $ */ Daniel@0: /* vim:set shiftwidth=4 ts=8: */ Daniel@0: Daniel@0: /********************************************************** Daniel@0: * This software is part of the graphviz package * Daniel@0: * http://www.graphviz.org/ * Daniel@0: * * Daniel@0: * Copyright (c) 1994-2004 AT&T Corp. * Daniel@0: * and is licensed under the * Daniel@0: * Common Public License, Version 1.0 * Daniel@0: * by AT&T Corp. * Daniel@0: * * Daniel@0: * Information and Software Systems Research * Daniel@0: * AT&T Research, Florham Park NJ * Daniel@0: **********************************************************/ Daniel@0: Daniel@0: /* Common header used by both clients and plugins */ Daniel@0: Daniel@0: #ifndef GVCJOB_H Daniel@0: #define GVCJOB_H Daniel@0: Daniel@0: #ifdef __cplusplus Daniel@0: extern "C" { Daniel@0: #endif Daniel@0: Daniel@0: #include "gvcommon.h" Daniel@0: #include "color.h" Daniel@0: Daniel@0: #define ARRAY_SIZE(A) (sizeof(A)/sizeof(A[0])) Daniel@0: Daniel@0: typedef struct gvdevice_engine_s gvdevice_engine_t; Daniel@0: typedef struct gvformatter_engine_s gvformatter_engine_t; Daniel@0: typedef struct gvrender_engine_s gvrender_engine_t; Daniel@0: typedef struct gvlayout_engine_s gvlayout_engine_t; Daniel@0: typedef struct gvtextlayout_engine_s gvtextlayout_engine_t; Daniel@0: typedef struct gvloadimage_engine_s gvloadimage_engine_t; Daniel@0: Daniel@0: typedef enum { PEN_NONE, PEN_DASHED, PEN_DOTTED, PEN_SOLID } pen_type; Daniel@0: typedef enum { FILL_NONE, FILL_SOLID } fill_type; Daniel@0: typedef enum { FONT_REGULAR, FONT_BOLD, FONT_ITALIC } font_type; Daniel@0: typedef enum { LABEL_PLAIN, LABEL_HTML } label_type; Daniel@0: Daniel@0: #define PENWIDTH_NORMAL 1. Daniel@0: #define PENWIDTH_BOLD 2. Daniel@0: typedef enum { GVATTR_STRING, GVATTR_BOOL, GVATTR_COLOR } gvattr_t; Daniel@0: Daniel@0: /* The -T output formats listed below are examples only, they are not definitive or inclusive, Daniel@0: other outputs may use the flags now, or in the future Daniel@0: Daniel@0: Default emit order is breadth first graph walk order Daniel@0: EMIT_SORTED emits nodes before edges Daniel@0: EMIT_COLORS emits colors before nodes or edge -Tfig Daniel@0: EMIT_CLUSTERS_LAST emits cluster after nodes and edges Daniel@0: EMIT_PREORDER emit in preorder traversal ??? Daniel@0: EMIT_EDGE_SORTED emits edges before nodes Daniel@0: Daniel@0: GVDEVICE_DOES_PAGES provides pagination support -Tps Daniel@0: GVDEVICE_DOES_LAYERS provides support for layers -Tps Daniel@0: GVDEVICE_EVENTS supports mouse events -Tgtk, -Txlib Daniel@0: GVDEVICE_DOES_TRUECOLOR supports alpha channel -Tpng, -Tgtk, -Txlib Daniel@0: GVDEVICE_BINARY_FORMAT Suppresses \r\n substitution for linends Daniel@0: GVDEVICE_COMPRESSED_FORMAT controls libz compression Daniel@0: 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) Daniel@0: Daniel@0: GVRENDER_Y_GOES_DOWN device origin top left, y goes down, otherwise Daniel@0: device origin lower left, y goes up Daniel@0: GVRENDER_DOES_TRANSFORM device uses scale, translate, rotate to do its own Daniel@0: coordinate transformations, otherwise coordinates Daniel@0: are pre-transformed Daniel@0: GVRENDER_DOES_ARROWS renderer has its own idea of arrow shapes (deprecated) Daniel@0: GVRENDER_DOES_LABELS basically, maps don't need labels Daniel@0: GVRENDER_DOES_MAPS renderer encodes mapping information for mouse events -Tcmapx -Tsvg Daniel@0: GVRENDER_DOES_MAP_RECTANGLE supports a 2 coord rectngle optimization Daniel@0: GVRENDER_DOES_MAP_CIRCLE supports a 1 coord + radius circle optimization Daniel@0: GVRENDER_DOES_MAP_POLYGON supports polygons (basically, -Tsvg uses anchors, so doesn't need to support any map shapes) Daniel@0: GVRENDER_DOES_MAP_ELLIPSE supports a 2 coord ellipse optimization Daniel@0: GVRENDER_DOES_MAP_BSPLINE supports mapping of splines Daniel@0: GVRENDER_DOES_TOOLTIPS can represent tooltip info -Tcmapx, -Tsvg Daniel@0: GVRENDER_DOES_TARGETS can represent target info (open link in a new tab or window) Daniel@0: GVRENDER_DOES_Z render support 2.5D representation -Tvrml Daniel@0: GVRENDER_NO_WHITE_BG don't paint white background, assumes white paper -Tps Daniel@0: LAYOUT_NOT_REQUIRED don't perform layout -Tcanon Daniel@0: OUTPUT_NOT_REQUIRED don't use gvdevice for output (basically when agwrite() used instead) -Tcanon, -Txdot Daniel@0: */ Daniel@0: Daniel@0: Daniel@0: #define EMIT_SORTED (1<<0) Daniel@0: #define EMIT_COLORS (1<<1) Daniel@0: #define EMIT_CLUSTERS_LAST (1<<2) Daniel@0: #define EMIT_PREORDER (1<<3) Daniel@0: #define EMIT_EDGE_SORTED (1<<4) Daniel@0: #define GVDEVICE_DOES_PAGES (1<<5) Daniel@0: #define GVDEVICE_DOES_LAYERS (1<<6) Daniel@0: #define GVDEVICE_EVENTS (1<<7) Daniel@0: #define GVDEVICE_DOES_TRUECOLOR (1<<8) Daniel@0: #define GVDEVICE_BINARY_FORMAT (1<<9) Daniel@0: #define GVDEVICE_COMPRESSED_FORMAT (1<<10) Daniel@0: #define GVDEVICE_NO_WRITER (1<<11) Daniel@0: #define GVRENDER_Y_GOES_DOWN (1<<12) Daniel@0: #define GVRENDER_DOES_TRANSFORM (1<<13) Daniel@0: #define GVRENDER_DOES_ARROWS (1<<14) Daniel@0: #define GVRENDER_DOES_LABELS (1<<15) Daniel@0: #define GVRENDER_DOES_MAPS (1<<16) Daniel@0: #define GVRENDER_DOES_MAP_RECTANGLE (1<<17) Daniel@0: #define GVRENDER_DOES_MAP_CIRCLE (1<<18) Daniel@0: #define GVRENDER_DOES_MAP_POLYGON (1<<19) Daniel@0: #define GVRENDER_DOES_MAP_ELLIPSE (1<<20) Daniel@0: #define GVRENDER_DOES_MAP_BSPLINE (1<<21) Daniel@0: #define GVRENDER_DOES_TOOLTIPS (1<<22) Daniel@0: #define GVRENDER_DOES_TARGETS (1<<23) Daniel@0: #define GVRENDER_DOES_Z (1<<24) Daniel@0: #define GVRENDER_NO_WHITE_BG (1<<25) Daniel@0: #define LAYOUT_NOT_REQUIRED (1<<26) Daniel@0: #define OUTPUT_NOT_REQUIRED (1<<27) Daniel@0: Daniel@0: typedef struct { Daniel@0: int flags; Daniel@0: double default_pad; /* graph units */ Daniel@0: char **knowncolors; Daniel@0: int sz_knowncolors; Daniel@0: color_type_t color_type; Daniel@0: } gvrender_features_t; Daniel@0: Daniel@0: typedef struct { Daniel@0: int flags; Daniel@0: pointf default_margin; /* left/right, top/bottom - points */ Daniel@0: pointf default_pagesize;/* default page width, height - points */ Daniel@0: pointf default_dpi; Daniel@0: } gvdevice_features_t; Daniel@0: Daniel@0: #define LAYOUT_USES_RANKDIR (1<<0) Daniel@0: Daniel@0: typedef struct gvplugin_active_device_s { Daniel@0: gvdevice_engine_t *engine; Daniel@0: int id; Daniel@0: gvdevice_features_t *features; Daniel@0: const char *type; Daniel@0: } gvplugin_active_device_t; Daniel@0: Daniel@0: typedef struct gvplugin_active_render_s { Daniel@0: gvrender_engine_t *engine; Daniel@0: int id; Daniel@0: gvrender_features_t *features; Daniel@0: const char *type; Daniel@0: } gvplugin_active_render_t; Daniel@0: Daniel@0: typedef struct gvplugin_active_loadimage_t { Daniel@0: gvloadimage_engine_t *engine; Daniel@0: int id; Daniel@0: const char *type; Daniel@0: } gvplugin_active_loadimage_t; Daniel@0: Daniel@0: typedef struct gv_argvlist_s { Daniel@0: char **argv; Daniel@0: int argc; Daniel@0: int alloc; Daniel@0: } gv_argvlist_t; Daniel@0: Daniel@0: typedef struct gvdevice_callbacks_s { Daniel@0: void (*refresh) (GVJ_t * job); Daniel@0: void (*button_press) (GVJ_t * job, int button, pointf pointer); Daniel@0: void (*button_release) (GVJ_t * job, int button, pointf pointer); Daniel@0: void (*motion) (GVJ_t * job, pointf pointer); Daniel@0: void (*modify) (GVJ_t * job, const char *name, const char *value); Daniel@0: void (*del) (GVJ_t * job); /* can't use "delete" 'cos C++ stole it */ Daniel@0: void (*read) (GVJ_t * job, const char *filename, const char *layout); Daniel@0: void (*layout) (GVJ_t * job, const char *layout); Daniel@0: void (*render) (GVJ_t * job, const char *format, const char *filename); Daniel@0: } gvdevice_callbacks_t; Daniel@0: Daniel@0: typedef int (*gvevent_key_callback_t) (GVJ_t * job); Daniel@0: Daniel@0: typedef struct gvevent_key_binding_s { Daniel@0: char *keystring; Daniel@0: gvevent_key_callback_t callback; Daniel@0: } gvevent_key_binding_t; Daniel@0: Daniel@0: typedef enum {MAP_RECTANGLE, MAP_CIRCLE, MAP_POLYGON, } map_shape_t; Daniel@0: Daniel@0: typedef enum {ROOTGRAPH_OBJTYPE, CLUSTER_OBJTYPE, NODE_OBJTYPE, EDGE_OBJTYPE} obj_type; Daniel@0: Daniel@0: /* See comment in gvrender_core_dot.c */ Daniel@0: typedef enum { Daniel@0: EMIT_GDRAW, EMIT_CDRAW, EMIT_TDRAW, EMIT_HDRAW, Daniel@0: EMIT_GLABEL, EMIT_CLABEL, EMIT_TLABEL, EMIT_HLABEL, Daniel@0: EMIT_NDRAW, EMIT_EDRAW, EMIT_NLABEL, EMIT_ELABEL, Daniel@0: } emit_state_t; Daniel@0: Daniel@0: typedef struct obj_state_s obj_state_t; Daniel@0: Daniel@0: struct obj_state_s { Daniel@0: obj_state_t *parent; Daniel@0: Daniel@0: obj_type type; Daniel@0: union { Daniel@0: graph_t *g; Daniel@0: graph_t *sg; Daniel@0: node_t *n; Daniel@0: edge_t *e; Daniel@0: } u; Daniel@0: Daniel@0: emit_state_t emit_state; Daniel@0: Daniel@0: gvcolor_t pencolor, fillcolor; Daniel@0: pen_type pen; Daniel@0: fill_type fill; Daniel@0: double penwidth; Daniel@0: char **rawstyle; Daniel@0: Daniel@0: double z, tail_z, head_z; /* z depths for 2.5D renderers such as vrml */ Daniel@0: Daniel@0: /* fully substituted text strings */ Daniel@0: char *label; Daniel@0: char *taillabel; Daniel@0: char *headlabel; Daniel@0: Daniel@0: char *url; /* if GVRENDER_DOES_MAPS */ Daniel@0: char *id; Daniel@0: char *labelurl; Daniel@0: char *tailurl; Daniel@0: char *headurl; Daniel@0: Daniel@0: char *tooltip; /* if GVRENDER_DOES_TOOLTIPS */ Daniel@0: char *labeltooltip; Daniel@0: char *tailtooltip; Daniel@0: char *headtooltip; Daniel@0: Daniel@0: char *target; /* if GVRENDER_DOES_TARGETS */ Daniel@0: char *labeltarget; Daniel@0: char *tailtarget; Daniel@0: char *headtarget; Daniel@0: Daniel@0: int explicit_tooltip:1; Daniel@0: int explicit_tailtooltip:1; Daniel@0: int explicit_headtooltip:1; Daniel@0: int explicit_labeltooltip:1; Daniel@0: int explicit_tailtarget:1; Daniel@0: int explicit_headtarget:1; Daniel@0: int explicit_edgetarget:1; Daniel@0: int explicit_tailurl:1; Daniel@0: int explicit_headurl:1; Daniel@0: Daniel@0: /* primary mapped region - node shape, edge labels */ Daniel@0: map_shape_t url_map_shape; Daniel@0: int url_map_n; /* number of points for url map if GVRENDER_DOES_MAPS */ Daniel@0: pointf *url_map_p; Daniel@0: Daniel@0: /* additonal mapped regions for edges */ Daniel@0: int url_bsplinemap_poly_n; /* number of polygons in url bspline map Daniel@0: if GVRENDER_DOES_MAPS && GVRENDER_DOES_MAP_BSPLINES */ Daniel@0: int *url_bsplinemap_n; /* array of url_bsplinemap_poly_n ints Daniel@0: of number of points in each polygon */ Daniel@0: pointf *url_bsplinemap_p; /* all the polygon points */ Daniel@0: Daniel@0: int tailendurl_map_n; /* tail end intersection with node */ Daniel@0: pointf *tailendurl_map_p; Daniel@0: Daniel@0: int headendurl_map_n; /* head end intersection with node */ Daniel@0: pointf *headendurl_map_p; Daniel@0: }; Daniel@0: Daniel@0: /* Note on units: Daniel@0: * points - a physical distance (1/72 inch) unaffected by zoom or dpi. Daniel@0: * graph units - related to physical distance by zoom. Equals points at zoom=1 Daniel@0: * device units - related to physical distance in points by dpi/72 Daniel@0: */ Daniel@0: Daniel@0: struct GVJ_s { Daniel@0: GVC_t *gvc; /* parent gvc */ Daniel@0: GVJ_t *next; /* linked list of jobs */ Daniel@0: GVJ_t *next_active; /* linked list of active jobs (e.g. multiple windows) */ Daniel@0: Daniel@0: GVCOMMON_t *common; Daniel@0: Daniel@0: obj_state_t *obj; /* objects can be nested (at least clusters can) Daniel@0: so keep object state on a stack */ Daniel@0: char *input_filename; Daniel@0: int graph_index; Daniel@0: Daniel@0: const char *layout_type; Daniel@0: Daniel@0: const char *output_filename; Daniel@0: FILE *output_file; Daniel@0: char *output_data; Daniel@0: unsigned int output_data_allocated; Daniel@0: unsigned int output_data_position; Daniel@0: Daniel@0: const char *output_langname; Daniel@0: int output_lang; Daniel@0: Daniel@0: gvplugin_active_render_t render; Daniel@0: gvplugin_active_device_t device; Daniel@0: gvplugin_active_loadimage_t loadimage; Daniel@0: gvdevice_callbacks_t *callbacks; Daniel@0: pointf device_dpi; Daniel@0: boolean device_sets_dpi; Daniel@0: Daniel@0: void *display; Daniel@0: int screen; Daniel@0: Daniel@0: void *context; /* gd or cairo surface */ Daniel@0: boolean external_context; /* context belongs to caller */ Daniel@0: char *imagedata; /* location of imagedata */ Daniel@0: Daniel@0: int flags; /* emit_graph flags */ Daniel@0: Daniel@0: int numLayers; /* number of layers */ Daniel@0: int layerNum; /* current layer - 1 based*/ Daniel@0: Daniel@0: point pagesArraySize; /* 2D size of page array */ Daniel@0: point pagesArrayFirst;/* 2D starting corner in */ Daniel@0: point pagesArrayMajor;/* 2D major increment */ Daniel@0: point pagesArrayMinor;/* 2D minor increment */ Daniel@0: point pagesArrayElem; /* 2D coord of current page - 0,0 based */ Daniel@0: int numPages; /* number of pages */ Daniel@0: Daniel@0: boxf bb; /* graph bb with padding - graph units */ Daniel@0: pointf pad; /* padding around bb - graph units */ Daniel@0: boxf clip; /* clip region in graph units */ Daniel@0: boxf pageBox; /* current page in graph units */ Daniel@0: pointf pageSize; /* page size in graph units */ Daniel@0: pointf focus; /* viewport focus - graph units */ Daniel@0: Daniel@0: double zoom; /* viewport zoom factor (points per graph unit) */ Daniel@0: int rotation; /* viewport rotation (degrees) 0=portrait, 90=landscape */ Daniel@0: Daniel@0: pointf view; /* viewport size - points */ Daniel@0: boxf canvasBox; /* viewport area - points */ Daniel@0: pointf margin; /* job-specific margin - points */ Daniel@0: Daniel@0: pointf dpi; /* device resolution device-units-per-inch */ Daniel@0: Daniel@0: unsigned int width; /* device width - device units */ Daniel@0: unsigned int height; /* device height - device units */ Daniel@0: box pageBoundingBox;/* rotated boundingBox - device units */ Daniel@0: box boundingBox; /* cumulative boundingBox over all pages - device units */ Daniel@0: Daniel@0: pointf scale; /* composite device to graph units (zoom and dpi) */ Daniel@0: pointf translation; /* composite translation */ Daniel@0: pointf devscale; /* composite device to points: dpi, y_goes_down */ Daniel@0: Daniel@0: boolean fit_mode, Daniel@0: needs_refresh, Daniel@0: click, Daniel@0: has_grown, Daniel@0: has_been_rendered; Daniel@0: Daniel@0: unsigned char button; /* active button */ Daniel@0: pointf pointer; /* pointer position in device units */ Daniel@0: pointf oldpointer; /* old pointer position in device units */ Daniel@0: Daniel@0: void *current_obj; /* graph object that pointer is in currently */ Daniel@0: Daniel@0: void *selected_obj; /* graph object that has been selected */ Daniel@0: /* (e.g. button 1 clicked on current obj) */ Daniel@0: char *active_tooltip; /* tooltip of active object - or NULL */ Daniel@0: char *selected_href; /* href of selected object - or NULL */ Daniel@0: gv_argvlist_t selected_obj_type_name; /* (e.g. "edge" "node3" "e" "->" "node5" "") */ Daniel@0: gv_argvlist_t selected_obj_attributes; /* attribute triplets: name, value, type */ Daniel@0: /* e.g. "color", "red", GVATTR_COLOR, Daniel@0: "style", "filled", GVATTR_BOOL, */ Daniel@0: Daniel@0: void *window; /* display-specific data for gvrender plugin */ Daniel@0: Daniel@0: /* keybindings for keyboard events */ Daniel@0: gvevent_key_binding_t *keybindings; Daniel@0: int numkeys; Daniel@0: void *keycodes; Daniel@0: }; Daniel@0: Daniel@0: #ifdef __cplusplus Daniel@0: } Daniel@0: #endif Daniel@0: #endif /* GVCJOB_H */