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