]> granicus.if.org Git - graphviz/commitdiff
move current graph object pointers from GVJ_t to GVC_t
authorellson <devnull@localhost>
Tue, 18 Oct 2005 18:47:05 +0000 (18:47 +0000)
committerellson <devnull@localhost>
Tue, 18 Oct 2005 18:47:05 +0000 (18:47 +0000)
lib/common/emit.c
lib/gvc/gvcint.h
lib/gvc/gvcjob.h [new file with mode: 0644]
lib/gvc/gvevent.c
lib/gvc/gvrender.c

index 8a1695ba07901234a7841003732ad38e9f3fe3b7..35ac33063c0a8b939bff21723e00a5b9ebe09e8a 100644 (file)
@@ -789,18 +789,6 @@ void emit_edge_graphics(GVJ_t * job, edge_t * e)
            color = late_nnstring(e, E_activefillcolor, DEFAULT_ACTIVEFILLCOLOR);
            gvrender_set_fillcolor(job, color);
        }
-       else if (ED_deleted(e)) {
-           color = late_nnstring(e, E_deletedpencolor, DEFAULT_DELETEDPENCOLOR);
-           gvrender_set_pencolor(job, color);
-           color = late_nnstring(e, E_deletedfillcolor, DEFAULT_DELETEDFILLCOLOR);
-           gvrender_set_fillcolor(job, color);
-       }
-       else if (ED_visited(e)) {
-           color = late_nnstring(e, E_visitedpencolor, DEFAULT_VISITEDPENCOLOR);
-           gvrender_set_pencolor(job, color);
-           color = late_nnstring(e, E_visitedfillcolor, DEFAULT_VISITEDFILLCOLOR);
-           gvrender_set_fillcolor(job, color);
-       }
        /* if more than one color - then generate parallel beziers, one per color */
        if (numc) {
            /* calculate and save offset vector spline and initialize first offset spline */
@@ -1421,18 +1409,6 @@ void emit_clusters(GVJ_t * job, Agraph_t * g, int flags)
            color = late_nnstring(sg, G_activefillcolor, DEFAULT_ACTIVEFILLCOLOR);
            gvrender_set_fillcolor(job, color);
        }
-       else if (GD_deleted(sg)) {
-           color = late_nnstring(e, G_deletedpencolor, DEFAULT_DELETEDPENCOLOR);
-           gvrender_set_pencolor(job, color);
-           color = late_nnstring(e, G_deletedfillcolor, DEFAULT_DELETEDFILLCOLOR);
-           gvrender_set_fillcolor(job, color);
-       }
-       else if (GD_visited(sg)) {
-           color = late_nnstring(e, G_visitedpencolor, DEFAULT_VISITEDPENCOLOR);
-           gvrender_set_pencolor(job, color);
-           color = late_nnstring(e, G_visitedfillcolor, DEFAULT_VISITEDFILLCOLOR);
-           gvrender_set_fillcolor(job, color);
-       }
        else {
            if (((color = agget(sg, "pencolor")) != 0) && color[0])
                gvrender_set_pencolor(job, color);
index 28145dfb88f7a22436a4f676fd604df982040a90..c6f652a8968cc7b947b2d0baa7be189d9edb563d 100644 (file)
@@ -81,6 +81,11 @@ extern "C" {
        GVJ_t *job;     /* current job */
        void (*errorfn) (char *fmt, ...);
 
+       graph_t *g;     /* current graph */
+       graph_t *sg;    /* current subgraph/cluster */
+       node_t *n;      /* current node */
+       edge_t *e;      /* current edge */
+
        /* plugins */
 #define ELEM(x) +1
        /* APIS expands to "+1 +1 ... +1" to give the number of APIs */
diff --git a/lib/gvc/gvcjob.h b/lib/gvc/gvcjob.h
new file mode 100644 (file)
index 0000000..2d0fd34
--- /dev/null
@@ -0,0 +1,198 @@
+/* $Id$ $Revision$ */
+/* vim:set shiftwidth=4 ts=8: */
+
+/**********************************************************
+*      This software is part of the graphviz package      *
+*                http://www.graphviz.org/                 *
+*                                                         *
+*            Copyright (c) 1994-2004 AT&T Corp.           *
+*                and is licensed under the                *
+*            Common Public License, Version 1.0           *
+*                      by AT&T Corp.                      *
+*                                                         *
+*        Information and Software Systems Research        *
+*              AT&T Research, Florham Park NJ             *
+**********************************************************/
+
+/* Common header used by both clients and plugins */
+
+#ifndef GVCJOB_H
+#define GVCJOB_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define ARRAY_SIZE(A) (sizeof(A)/sizeof(A[0]))
+
+    typedef enum { PEN_NONE, PEN_DASHED, PEN_DOTTED, PEN_SOLID } pen_type;
+    typedef enum { FILL_NONE, FILL_SOLID } fill_type;
+    typedef enum { FONT_REGULAR, FONT_BOLD, FONT_ITALIC } font_type;
+#define PENWIDTH_NORMAL 1.
+#define PENWIDTH_BOLD 2.
+
+    typedef struct {
+       char *fontfam, fontopt;
+       color_t pencolor, fillcolor;
+       pen_type pen;
+       fill_type fill;
+       double penwidth;
+       double fontsz;
+    } gvstyle_t;
+
+#define EMIT_SORTED (1<<0)
+#define EMIT_COLORS (1<<1)
+#define EMIT_CLUSTERS_LAST (1<<2)
+#define EMIT_PREORDER (1<<3)
+#define EMIT_EDGE_SORTED (1<<4)
+#define GVRENDER_DOES_ARROWS (1<<5)
+#define GVRENDER_DOES_LAYERS (1<<6)
+#define GVRENDER_DOES_MULTIGRAPH_OUTPUT_FILES (1<<7)
+#define GVRENDER_DOES_TRUECOLOR (1<<8)
+#define GVRENDER_Y_GOES_DOWN (1<<9)
+#define GVRENDER_X11_EVENTS (1<<10)
+#define GVRENDER_DOES_TRANSFORM (1<<11)
+
+    typedef struct {
+       int flags;
+       double default_margin; /* graph units */
+       int default_dpi;
+       char **knowncolors;
+       int sz_knowncolors;
+       color_type_t color_type;
+       char *device;
+    } gvrender_features_t;
+
+    typedef struct {
+       int flags;
+    } gvdevice_features_t;
+
+#define LAYOUT_USES_RANKDIR (1<<0)
+
+    /* active plugin headers */
+    typedef struct gvplugin_active_device_s {
+        gvdevice_engine_t *engine;
+        int id;
+        gvdevice_features_t *features;
+    } gvplugin_active_device_t;
+
+    typedef struct gvplugin_active_render_s {
+        gvrender_engine_t *engine;
+        int id;
+        gvrender_features_t *features;
+        char *type;
+    } gvplugin_active_render_t;
+
+    /*
+     * gv_matrix_t:   (compat with cairo_matrix_t)
+     *
+     * A #gv_matrix_t holds an affine transformation, such as a scale,
+     * rotation, or shear, or a combination of those.
+     */
+    typedef struct gv_matrix_s {
+       double xx; double yx;
+       double xy; double yy;
+       double x0; double y0;
+    } gv_matrix_t;
+
+    typedef struct gv_argvlist_s {
+       char **argv;
+       int argc;
+       int alloc;
+    } gv_argvlist_t;
+
+    typedef struct gvdevice_callbacks_s {
+       void (*refresh) (GVJ_t * job);
+        void (*button_press) (GVJ_t * job, int button, pointf pointer);
+        void (*button_release) (GVJ_t * job, int button, pointf pointer);
+        void (*motion) (GVJ_t * job, pointf pointer);
+        void (*modify) (GVJ_t * job, char *name, char *value);
+    } gvdevice_callbacks_t;
+
+    struct GVJ_s {
+       GVC_t *gvc;             /* parent gvc */
+       GVJ_t *next;            /* linked list of jobs */
+       GVJ_t *next_active;     /* linked list of active jobs (e.g. multiple windows) */
+       char *output_filename;
+       char *output_langname;
+       FILE *output_file;
+       int output_lang;
+
+       gvplugin_active_render_t render;
+       gvplugin_active_device_t device;
+       gvdevice_callbacks_t *callbacks;
+
+#ifndef DISABLE_CODEGENS
+       codegen_t *codegen;     /* current  codegen */
+#endif
+
+       void *surface;          /* gd or cairo surface */
+       bool external_surface; /* surface belongs to caller */
+
+       gvstyle_t *style;       /* active style from gvc->styles[] */
+
+        int flags;             /* emit_graph flags */
+
+        pointf margin;          /* job-specific margin - graph units */
+
+       int numLayers;          /* number of layers */
+       int layerNum;           /* current layer - 1 based*/
+
+       boxf    pageBox;         /* current page in graph coords */
+       pointf  pageOffset;      /* offset for current page in graph coords */
+       pointf  pageSize;        /* page size in graph units */
+       point   pagesArraySize;  /* 2D size of page array */
+       point   pagesArrayFirst; /* 2D starting corner in */
+       point   pagesArrayMajor; /* 2D major increment */
+       point   pagesArrayMinor; /* 2D minor increment */
+       point   pagesArrayElem;  /* 2D coord of current page - 0,0 based */
+        int    numPages;        /* number of pages */
+
+        unsigned int width;     /* device width in device units */
+        unsigned int height;    /* device height in device units */
+       int dpi;                /* device resolution device-units-per-inch */
+       double zoom;            /* viewport zoom factor */
+       int rotation;           /* viewport rotation  0=portrait, 1=landscape */
+       pointf focus;           /* viewport focus in graph units */
+       box     boundingBox;    /* drawable region in device units */
+
+       boxf clip;              /* clip region in graph units */
+       boxf pageBoxClip;       /* intersection of clip and pageBox */
+
+       gv_matrix_t transform;  /* transformation matrix for renderers that can use it */
+       pointf compscale;       /* composite device scale incl: scale, zoom, dpi, y_goes_down */
+       pointf offset;          /* composite translation */
+       
+       bool fit_mode,
+               needs_refresh,
+               click,
+               active,
+               has_grown;
+
+       pointf pointer;         /* pointer position in device units */
+       pointf oldpointer;      /* old pointer position in device units */
+
+       void *current_obj;      /* graph object that pointer is in currently */
+
+       void *selected_obj;      /* graph object that has been selected */
+                                       /* (e.g. button 1 clicked on current obj) */
+       char *active_tooltip;           /* tooltip of active object - or NULL */
+       char *selected_href;            /* href of selected object - or NULL */
+       gv_argvlist_t selected_obj_type_name; /* (e.g. "edge" "node3" "e" "->" "node5" "") */
+       gv_argvlist_t selected_obj_attributes; /* even args are names, odd are values */
+                               /* e.g. "color" "red" "style" "filled" */
+
+       void *window;           /* display-specific data for gvrender plugin */
+    };
+
+    typedef int (*gvevent_key_callback_t) (GVJ_t * job);
+
+    typedef struct gvevent_key_binding_s {
+       char *keystring;
+       gvevent_key_callback_t callback;
+    } gvevent_key_binding_t;
+
+#ifdef __cplusplus
+}
+#endif
+#endif                         /* GVCJOB_H */
index 21525a83238c5c0f20f29b97b0807f53d8439038..3a2f52aa9cac8e8207a88a8eb1bf4027c9ed2a72 100644 (file)
@@ -166,12 +166,14 @@ static void gv_edge_state(GVJ_t *job, edge_t *e)
 
 static void gvevent_refresh(GVJ_t * job)
 {
+    graph_t *g = job->gvc->g;
+
     if (!job->selected_obj) {
-       job->selected_obj = job->g;
-       GD_selected(job->g) = TRUE;
-       gv_graph_state(job, job->g);
+       job->selected_obj = g;
+       GD_selected(g) = TRUE;
+       gv_graph_state(job, g);
     }
-    emit_graph(job, job->g);
+    emit_graph(job, g);
 }
 
 /* recursively find innermost cluster containing the point */
@@ -302,7 +304,7 @@ static void gvevent_find_current_obj(GVJ_t * job, pointf pointer)
     b.LL.x = p.x - closeenough;
     b.LL.y = p.y - closeenough;
 
-    obj = gvevent_find_obj(job->g, b);
+    obj = gvevent_find_obj(job->gvc->g, b);
     if (obj != job->current_obj) {
        gvevent_leave_obj(job);
        job->current_obj = obj;
index 0db8388b13fa652939c6fdcd792bcaaef301bf71..134a9ed3080c09b75b662c498a66a04c2178dac5 100644 (file)
@@ -122,6 +122,7 @@ int gvrender_features(GVJ_t * job)
 
 void gvrender_begin_job(GVJ_t * job)
 {
+    GVC_t *gvc = job->gvc;
     gvrender_engine_t *gvre = job->render.engine;
 
     if (gvre) {
@@ -133,8 +134,8 @@ void gvrender_begin_job(GVJ_t * job)
        codegen_t *cg = job->codegen;
 
        if (cg && cg->begin_job)
-           cg->begin_job(job->output_file, job->g, job->gvc->lib, job->gvc->user,
-                         job->gvc->info, job->pagesArraySize);
+           cg->begin_job(job->output_file, gvc->g, gvc->lib, gvc->user,
+                         gvc->info, job->pagesArraySize);
     }
 #endif
 }
@@ -231,7 +232,7 @@ void gvrender_begin_graph(GVJ_t * job, graph_t * g)
     sx = job->width / (job->zoom * 2.);
     sy = job->height / (job->zoom * 2.);
 
-    job->sg = g;  /* current subgraph/cluster */
+    gvc->sg = g;  /* current subgraph/cluster */
     job->compscale.y = job->compscale.x = job->zoom * job->dpi / POINTS_PER_INCH;
     job->compscale.y *= (job->flags & GVRENDER_Y_GOES_DOWN) ? -1. : 1.;
     if (job->rotation) {
@@ -323,7 +324,7 @@ void gvrender_end_graph(GVJ_t * job)
            cg->end_graph();
     }
 #endif
-    job->sg = NULL;
+    job->gvc->sg = NULL;
 }
 
 void gvrender_begin_page(GVJ_t * job)
@@ -340,7 +341,7 @@ void gvrender_begin_page(GVJ_t * job)
 
        PF2P(job->pageOffset, offset);
        if (cg && cg->begin_page)
-           cg->begin_page(job->g, job->pagesArrayElem,
+           cg->begin_page(job->gvc->g, job->pagesArrayElem,
                job->zoom, job->rotation, offset);
     }
 #endif
@@ -398,7 +399,7 @@ void gvrender_begin_cluster(GVJ_t * job, graph_t * sg)
 {
     gvrender_engine_t *gvre = job->render.engine;
 
-    job->sg = sg;  /* set current cluster graph object */
+    job->gvc->sg = sg;  /* set current cluster graph object */
 #ifndef DISABLE_CODEGENS
     Obj = CLST;
 #endif
@@ -429,7 +430,7 @@ void gvrender_end_cluster(GVJ_t * job, graph_t *g)
     }
     Obj = NONE;
 #endif
-    job->sg = g;  /* reset current cluster to parent graph or cluster */
+    job->gvc->sg = g;  /* reset current cluster to parent graph or cluster */
 }
 
 void gvrender_begin_nodes(GVJ_t * job)
@@ -503,7 +504,7 @@ void gvrender_begin_node(GVJ_t * job, node_t * n)
 #ifndef DISABLE_CODEGENS
     Obj = NODE;
 #endif
-    job->n = n; /* set current node */
+    job->gvc->n = n; /* set current node */
     if (gvre && gvre->begin_node)
        gvre->begin_node(job, n->name, n->id);
 #ifndef DISABLE_CODEGENS
@@ -531,7 +532,7 @@ void gvrender_end_node(GVJ_t * job)
     }
     Obj = NONE;
 #endif
-    job->n = NULL; /* clear current node */
+    job->gvc->n = NULL; /* clear current node */
 }
 
 void gvrender_begin_edge(GVJ_t * job, edge_t * e)
@@ -541,7 +542,7 @@ void gvrender_begin_edge(GVJ_t * job, edge_t * e)
 #ifndef DISABLE_CODEGENS
     Obj = EDGE;
 #endif
-    job->e = e; /* set current edge */
+    job->gvc->e = e; /* set current edge */
     if (gvre && gvre->begin_edge)
        gvre->begin_edge(job, e->tail->name,
                         e->tail->graph->root->kind & AGFLAG_DIRECTED,
@@ -571,7 +572,7 @@ void gvrender_end_edge(GVJ_t * job)
     }
     Obj = NONE;
 #endif
-    job->e = NULL; /* clear current edge */
+    job->gvc->e = NULL; /* clear current edge */
 }
 
 void gvrender_begin_context(GVJ_t * job)