From b4135653a9b7c376180a897543484fbf94480527 Mon Sep 17 00:00:00 2001 From: erg Date: Thu, 30 Sep 2010 20:17:39 +0000 Subject: [PATCH] Prototype new version of xdot providing anchor information --- plugin/core/gvrender_core_dot.c | 52 +++++++++++++++++++++++++++++++-- 1 file changed, 49 insertions(+), 3 deletions(-) diff --git a/plugin/core/gvrender_core_dot.c b/plugin/core/gvrender_core_dot.c index 978066a6a..808f2c0a0 100644 --- a/plugin/core/gvrender_core_dot.c +++ b/plugin/core/gvrender_core_dot.c @@ -38,6 +38,8 @@ #define GNEW(t) (t*)malloc(sizeof(t)) +/* #define NEW_XDOT */ + typedef enum { FORMAT_DOT, FORMAT_CANON, @@ -246,6 +248,42 @@ static void xdot_end_edge(GVJ_t* job) penwidth[EMIT_HLABEL] = 1; } +#ifdef NEW_XDOT +/* xdot_begin_anchor: + * The encoding of which fields are present assumes that one of the fields is present, + * so there is never a 0 after the H. + */ +static void xdot_begin_anchor(GVJ_t * job, char *href, char *tooltip, char *target, char *id) +{ + emit_state_t emit_state = job->obj->emit_state; + char buf[3]; /* very small integer */ + unsigned int flags = 0; + + agxbput(xbufs[emit_state], "H "); + if (href) + flags |= 1; + if (tooltip) + flags |= 2; + if (target) + flags |= 4; + sprintf (buf, "%d ", flags); + agxbput(xbufs[emit_state], buf); + if (href) + xdot_str (job, "", href); + if (tooltip) + xdot_str (job, "", tooltip); + if (target) + xdot_str (job, "", target); +} + +static void xdot_end_anchor(GVJ_t * job) +{ + emit_state_t emit_state = job->obj->emit_state; + + agxbput(xbufs[emit_state], "H 0 "); +} +#endif + static void xdot_end_cluster(GVJ_t * job) { Agraph_t* cluster_g = job->obj->u.sg; @@ -609,8 +647,13 @@ gvrender_engine_t xdot_engine = { xdot_end_node, 0, /* xdot_begin_edge */ xdot_end_edge, - 0, /* xdot_begin_anchor */ - 0, /* xdot_end_anchor */ +#ifdef NEW_XDOT + xdot_begin_anchor, + xdot_end_anchor, +#else + 0, /* xdot_begin_anchor */ + 0, /* xdot_end_anchor */ +#endif 0, /* xdot_begin_label */ 0, /* xdot_end_label */ xdot_textpara, @@ -632,7 +675,10 @@ gvrender_features_t render_features_dot = { }; gvrender_features_t render_features_xdot = { - GVRENDER_DOES_TRANSFORM, /* not really - uses raw graph coords */ /* flags */ + GVRENDER_DOES_TRANSFORM /* not really - uses raw graph coords */ + | GVRENDER_DOES_MAPS + | GVRENDER_DOES_TARGETS + | GVRENDER_DOES_TOOLTIPS, /* flags */ 0., /* default pad - graph units */ NULL, /* knowncolors */ 0, /* sizeof knowncolors */ -- 2.40.0