Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /include/graphviz/gvcjob.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 /// @file
0002 /// @ingroup gvc_api
0003 /*************************************************************************
0004  * Copyright (c) 2011 AT&T Intellectual Property 
0005  * All rights reserved. This program and the accompanying materials
0006  * are made available under the terms of the Eclipse Public License v1.0
0007  * which accompanies this distribution, and is available at
0008  * https://www.eclipse.org/legal/epl-v10.html
0009  *
0010  * Contributors: Details at https://graphviz.org
0011  *************************************************************************/
0012 
0013 /* Common header used by both clients and plugins */
0014 
0015 #pragma once
0016 
0017 #ifdef __cplusplus
0018 extern "C" {
0019 #endif
0020 
0021 #include "gvcommon.h"
0022 #include "color.h"
0023 #include <stdbool.h>
0024 #include <stddef.h>
0025 
0026 #define ARRAY_SIZE(A) (sizeof(A)/sizeof(A[0]))
0027 
0028     typedef struct gvdevice_engine_s gvdevice_engine_t;
0029     typedef struct gvformatter_engine_s gvformatter_engine_t;
0030     typedef struct gvrender_engine_s gvrender_engine_t;
0031     typedef struct gvlayout_engine_s gvlayout_engine_t;
0032     typedef struct gvtextlayout_engine_s gvtextlayout_engine_t;
0033     typedef struct gvloadimage_engine_s gvloadimage_engine_t;
0034 
0035     typedef enum { PEN_NONE, PEN_DASHED, PEN_DOTTED, PEN_SOLID } pen_type;
0036     typedef enum { FILL_NONE, FILL_SOLID, FILL_LINEAR, FILL_RADIAL } fill_type;
0037     typedef enum { FONT_REGULAR, FONT_BOLD, FONT_ITALIC } font_type;
0038     typedef enum { LABEL_PLAIN, LABEL_HTML } label_type;
0039 
0040 #define PENWIDTH_NORMAL 1.
0041 #define PENWIDTH_BOLD 2.
0042 
0043 /* The -T output formats listed below are examples only, they are not definitive or inclusive,
0044  other outputs may use the flags now, or in the future 
0045 
0046                    Default emit order is breadth first graph walk order 
0047  EMIT_SORTED            emits nodes before edges        
0048  EMIT_COLORS            emits colors before nodes or edge -Tfig 
0049  EMIT_CLUSTERS_LAST     emits cluster after nodes and edges     
0050  EMIT_PREORDER          emit in preorder traversal ???      
0051  EMIT_EDGE_SORTED       emits edges before nodes        
0052 
0053  GVDEVICE_DOES_PAGES        provides pagination support -Tps    
0054  GVDEVICE_DOES_LAYERS       provides support for layers -Tps    
0055  GVDEVICE_EVENTS        supports mouse events -Txlib    
0056  GVDEVICE_DOES_TRUECOLOR    supports alpha channel -Tpng, -Txlib
0057  GVDEVICE_BINARY_FORMAT     Suppresses \r\n substitution for linends 
0058  GVDEVICE_COMPRESSED_FORMAT controls libz compression       
0059  GVDEVICE_NO_WRITER     used when gvdevice is not used because device uses its own writer, devil outputs   (FIXME seems to overlap OUTPUT_NOT_REQUIRED)
0060 
0061  GVRENDER_Y_GOES_DOWN       device origin top left, y goes down, otherwise
0062                 device origin lower left, y goes up 
0063  GVRENDER_DOES_TRANSFORM    device uses scale, translate, rotate to do its own
0064                 coordinate transformations, otherwise coordinates 
0065                 are pre-transformed         
0066  GVRENDER_DOES_LABELS       basically, maps don't need labels   
0067  GVRENDER_DOES_MAPS     renderer encodes mapping information for mouse events -Tcmapx -Tsvg 
0068  GVRENDER_DOES_MAP_RECTANGLE    supports a 2 coord rectngle optimization 
0069  GVRENDER_DOES_MAP_CIRCLE   supports a 1 coord + radius circle optimization 
0070  GVRENDER_DOES_MAP_POLYGON  supports polygons (basically, -Tsvg uses anchors, so doesn't need to support any map shapes) 
0071  GVRENDER_DOES_MAP_ELLIPSE  supports a 2 coord ellipse optimization 
0072  GVRENDER_DOES_MAP_BSPLINE  supports mapping of splines     
0073  GVRENDER_DOES_TOOLTIPS     can represent tooltip info -Tcmapx, -Tsvg       
0074  GVRENDER_DOES_TARGETS      can represent target info (open link in a new tab or window) 
0075  GVRENDER_DOES_Z        render support 2.5D representation -Tvrml 
0076  GVRENDER_NO_WHITE_BG       don't paint white background, assumes white paper -Tps 
0077  LAYOUT_NOT_REQUIRED        don't perform layout -Tcanon        
0078  OUTPUT_NOT_REQUIRED        don't use gvdevice for output (basically when agwrite() used instead) -Tcanon, -Txdot 
0079  */
0080 
0081 
0082 #define EMIT_SORTED (1<<0)
0083 #define EMIT_COLORS (1<<1)
0084 #define EMIT_CLUSTERS_LAST (1<<2)
0085 #define EMIT_PREORDER (1<<3)
0086 #define EMIT_EDGE_SORTED (1<<4)
0087 #define GVDEVICE_DOES_PAGES (1<<5)
0088 #define GVDEVICE_DOES_LAYERS (1<<6)
0089 #define GVDEVICE_EVENTS (1<<7)
0090 #define GVDEVICE_DOES_TRUECOLOR (1<<8)
0091 #define GVDEVICE_BINARY_FORMAT (1<<9)
0092 #define GVDEVICE_COMPRESSED_FORMAT (1<<10)
0093 #define GVDEVICE_NO_WRITER (1<<11)
0094 #define GVRENDER_Y_GOES_DOWN (1<<12)
0095 #define GVRENDER_DOES_TRANSFORM (1<<13)
0096 #define GVRENDER_DOES_LABELS (1<<15)
0097 #define GVRENDER_DOES_MAPS (1<<16)
0098 #define GVRENDER_DOES_MAP_RECTANGLE (1<<17)
0099 #define GVRENDER_DOES_MAP_CIRCLE (1<<18)
0100 #define GVRENDER_DOES_MAP_POLYGON (1<<19)
0101 #define GVRENDER_DOES_MAP_ELLIPSE (1<<20)
0102 #define GVRENDER_DOES_MAP_BSPLINE (1<<21)
0103 #define GVRENDER_DOES_TOOLTIPS (1<<22)
0104 #define GVRENDER_DOES_TARGETS (1<<23)
0105 #define GVRENDER_DOES_Z (1<<24)
0106 #define GVRENDER_NO_WHITE_BG (1<<25)
0107 #define LAYOUT_NOT_REQUIRED (1<<26)
0108 #define OUTPUT_NOT_REQUIRED (1<<27)
0109 
0110     typedef struct {
0111     int flags;
0112     double default_pad; /* graph units */
0113     char **knowncolors;
0114     int sz_knowncolors;
0115     color_type_t color_type;
0116     } gvrender_features_t;
0117 
0118     typedef struct {
0119     int flags;
0120     pointf default_margin;  /* left/right, top/bottom - points */
0121     pointf default_pagesize;/* default page width, height - points */
0122     pointf default_dpi;
0123     } gvdevice_features_t;
0124 
0125 #define LAYOUT_USES_RANKDIR (1<<0)
0126 
0127     typedef struct gvplugin_active_device_s {
0128         gvdevice_engine_t *engine;
0129         int id;
0130         gvdevice_features_t *features;
0131         const char *type;
0132     } gvplugin_active_device_t;
0133 
0134     typedef struct gvplugin_active_render_s {
0135         gvrender_engine_t *engine;
0136         int id;
0137         gvrender_features_t *features;
0138         const char *type;
0139     } gvplugin_active_render_t;
0140 
0141     typedef struct gvplugin_active_loadimage_t {
0142     gvloadimage_engine_t *engine;
0143     int id;
0144     const char *type;
0145     } gvplugin_active_loadimage_t;
0146     
0147     typedef struct gvdevice_callbacks_s {
0148     void (*refresh) (GVJ_t * job);
0149         void (*button_press) (GVJ_t * job, int button, pointf pointer);
0150         void (*button_release) (GVJ_t * job, int button, pointf pointer);
0151         void (*motion) (GVJ_t * job, pointf pointer);
0152         void (*modify) (GVJ_t * job, const char *name, const char *value);
0153         void (*del) (GVJ_t * job);  /* can't use "delete" 'cos C++ stole it */
0154         void (*read) (GVJ_t * job, const char *filename, const char *layout);
0155         void (*layout) (GVJ_t * job, const char *layout);
0156         void (*render) (GVJ_t * job, const char *format, const char *filename);
0157     } gvdevice_callbacks_t;
0158 
0159     typedef int (*gvevent_key_callback_t) (GVJ_t * job);
0160 
0161     typedef struct gvevent_key_binding_s {
0162     char *keystring;
0163     gvevent_key_callback_t callback;
0164     } gvevent_key_binding_t;
0165 
0166     typedef enum {MAP_RECTANGLE, MAP_CIRCLE, MAP_POLYGON, } map_shape_t;
0167 
0168     typedef enum {ROOTGRAPH_OBJTYPE, CLUSTER_OBJTYPE, NODE_OBJTYPE, EDGE_OBJTYPE} obj_type;
0169 
0170     /* If this enum is changed, the implementation of xbuf and xbufs in
0171      * gvrender_core_dot.c will probably need to be changed.
0172      */
0173     typedef enum {
0174     EMIT_GDRAW, EMIT_CDRAW, EMIT_TDRAW, EMIT_HDRAW, 
0175     EMIT_GLABEL, EMIT_CLABEL, EMIT_TLABEL, EMIT_HLABEL, 
0176     EMIT_NDRAW, EMIT_EDRAW, EMIT_NLABEL, EMIT_ELABEL,
0177     } emit_state_t;
0178 
0179     typedef struct obj_state_s obj_state_t;
0180 
0181     struct obj_state_s {
0182     obj_state_t *parent;
0183 
0184     obj_type type;
0185     union {
0186         graph_t *g;
0187         graph_t *sg;  
0188         node_t *n;
0189         edge_t *e;
0190     } u;
0191 
0192     emit_state_t emit_state; 
0193 
0194     gvcolor_t pencolor, fillcolor, stopcolor;
0195     int gradient_angle;
0196     double gradient_frac;
0197     pen_type pen;
0198     fill_type fill;
0199     double penwidth;
0200     char **rawstyle;
0201 
0202     double z, tail_z, head_z;   /* z depths for 2.5D renderers such as vrml */
0203 
0204     /* fully substituted text strings */
0205     char *label;
0206     char *xlabel;
0207     char *taillabel;
0208     char *headlabel; 
0209 
0210     char *url;              /* if GVRENDER_DOES_MAPS */
0211     char *id;
0212     char *labelurl;
0213     char *tailurl;
0214     char *headurl; 
0215 
0216     char *tooltip;          /* if GVRENDER_DOES_TOOLTIPS */
0217     char *labeltooltip;
0218     char *tailtooltip;
0219     char *headtooltip; 
0220 
0221     char *target;           /* if GVRENDER_DOES_TARGETS */
0222     char *labeltarget;
0223     char *tailtarget;
0224     char *headtarget; 
0225 
0226     unsigned explicit_tooltip:1;
0227     unsigned explicit_tailtooltip:1;
0228     unsigned explicit_headtooltip:1;
0229     unsigned explicit_labeltooltip:1;
0230     unsigned explicit_tailtarget:1;
0231     unsigned explicit_headtarget:1;
0232     unsigned explicit_edgetarget:1;
0233     unsigned explicit_tailurl:1;
0234     unsigned explicit_headurl:1;
0235     unsigned labeledgealigned:1;
0236 
0237     /* primary mapped region - node shape, edge labels */
0238     map_shape_t url_map_shape; 
0239     size_t url_map_n; // number of points for url map if GVRENDER_DOES_MAPS
0240     pointf *url_map_p;
0241 
0242     /* additional mapped regions for edges */
0243     size_t url_bsplinemap_poly_n;      /* number of polygons in url bspline map
0244                      if GVRENDER_DOES_MAPS && GVRENDER_DOES_MAP_BSPLINES */
0245     size_t *url_bsplinemap_n;          /* array of url_bsplinemap_poly_n ints 
0246                      of number of points in each polygon */
0247     pointf *url_bsplinemap_p;       /* all the polygon points */
0248 
0249     int tailendurl_map_n;           /* tail end intersection with node */
0250     pointf *tailendurl_map_p;
0251 
0252     int headendurl_map_n;           /* head end intersection with node */
0253     pointf *headendurl_map_p;
0254     };
0255 
0256 /* Note on units:
0257  *     points  - a physical distance (1/72 inch) unaffected by zoom or dpi.
0258  *     graph units - related to physical distance by zoom.  Equals points at zoom=1
0259  *     device units - related to physical distance in points by dpi/72
0260  */
0261 
0262     struct GVJ_s {
0263     GVC_t *gvc;     /* parent gvc */
0264     GVJ_t *next;        /* linked list of jobs */
0265     GVJ_t *next_active; /* linked list of active jobs (e.g. multiple windows) */
0266 
0267     GVCOMMON_t *common;
0268 
0269     obj_state_t *obj;   /* objects can be nested (at least clusters can)
0270                     so keep object state on a stack */
0271     char *input_filename;
0272     int graph_index;
0273 
0274     const char *layout_type;
0275 
0276     const char *output_filename;
0277     FILE *output_file;
0278     char *output_data;
0279     unsigned int output_data_allocated;
0280     unsigned int output_data_position;
0281 
0282     const char *output_langname;
0283     int output_lang;
0284 
0285     gvplugin_active_render_t render;
0286     gvplugin_active_device_t device;
0287     gvplugin_active_loadimage_t loadimage;
0288     gvdevice_callbacks_t *callbacks;
0289     pointf device_dpi;
0290     bool device_sets_dpi;
0291 
0292     void *display;
0293     int screen;
0294 
0295     void *context;      /* gd or cairo surface */
0296     bool external_context;  /* context belongs to caller */
0297     char *imagedata;    /* location of imagedata */
0298 
0299         int flags;      /* emit_graph flags */
0300 
0301     int numLayers;      /* number of layers */
0302     int layerNum;       /* current layer - 1 based*/
0303 
0304     point   pagesArraySize; /* 2D size of page array */
0305     point   pagesArrayFirst;/* 2D starting corner in */
0306     point   pagesArrayMajor;/* 2D major increment */
0307     point   pagesArrayMinor;/* 2D minor increment */
0308     point   pagesArrayElem; /* 2D coord of current page - 0,0 based */
0309         int numPages;   /* number of pages */
0310 
0311     boxf    bb;     /* graph bb with padding - graph units */
0312     pointf  pad;        /* padding around bb - graph units */
0313     boxf    clip;       /* clip region in graph units */
0314     boxf    pageBox;    /* current page in graph units */
0315     pointf  pageSize;   /* page size in graph units */
0316     pointf  focus;      /* viewport focus - graph units */
0317 
0318     double  zoom;       /* viewport zoom factor (points per graph unit) */
0319     int rotation;   /* viewport rotation (degrees)  0=portrait, 90=landscape */
0320 
0321     pointf  view;       /* viewport size - points */
0322     boxf    canvasBox;  /* viewport area - points */
0323         pointf  margin;     /* job-specific margin - points */
0324 
0325     pointf  dpi;        /* device resolution device-units-per-inch */
0326 
0327         unsigned int width;     /* device width - device units */
0328         unsigned int height;    /* device height - device units */
0329     box     pageBoundingBox;/* rotated boundingBox - device units */
0330     box     boundingBox;    /* cumulative boundingBox over all pages - device units */
0331 
0332     pointf  scale;      /* composite device to graph units (zoom and dpi) */
0333     pointf  translation;    /* composite translation */
0334     pointf  devscale;   /* composite device to points: dpi, y_goes_down */
0335 
0336     bool    fit_mode,
0337         needs_refresh,
0338         click,
0339         has_grown,
0340         has_been_rendered;
0341 
0342     unsigned char button;   /* active button */
0343     pointf pointer;     /* pointer position in device units */
0344     pointf oldpointer;  /* old pointer position in device units */
0345 
0346     void *current_obj;      /* graph object that pointer is in currently */
0347 
0348     void *selected_obj;      /* graph object that has been selected */
0349                     /* (e.g. button 1 clicked on current obj) */
0350     char *active_tooltip;       /* tooltip of active object - or NULL */
0351     char *selected_href;        /* href of selected object - or NULL */
0352 
0353     void *window;       /* display-specific data for gvrender plugin */
0354 
0355         /* keybindings for keyboard events */
0356     gvevent_key_binding_t *keybindings;
0357     size_t numkeys;
0358     void *keycodes;
0359     };
0360 
0361 #ifdef __cplusplus
0362 }
0363 #endif