From: ellson Date: Thu, 23 Oct 2008 21:04:05 +0000 (+0000) Subject: use macros X-Git-Tag: LAST_LIBGRAPH~32^2~2966 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=46f403a80d5e4ae574689a8b657432334ab68272;p=graphviz use macros --- diff --git a/lib/gvc/gvevent.c b/lib/gvc/gvevent.c index 79895a217..449ed0440 100644 --- a/lib/gvc/gvevent.c +++ b/lib/gvc/gvevent.c @@ -91,17 +91,13 @@ static void gv_graph_state(GVJ_t *job, graph_t *g) } list->argc = j; -#ifndef WITH_CGRAPH - a = agfindattr(g->root, s_href); + a = agfindgraphattr(agroot(g), s_href); if (!a) - a = agfindattr(g->root, s_URL); + a = agfindgraphattr(agroot(g), s_URL); if (a) +#ifndef WITH_CGRAPH job->selected_href = strdup_and_subst_obj(agxget(g, a->index), (void*)g); #else - a = agattr(agroot(g), AGRAPH, s_href, NULL); - if (!a) - a = agattr(agroot(g), AGRAPH, s_URL, NULL); - if (a) job->selected_href = strdup_and_subst_obj(agxget(g, a), (void*)g); #endif } @@ -140,17 +136,13 @@ static void gv_node_state(GVJ_t *job, node_t *n) } list->argc = j; -#ifndef WITH_CGRAPH - a = agfindattr(n->graph->proto->n, s_href); + a = agfindnodeattr(agraphof(n), s_href); if (!a) - a = agfindattr(n->graph->proto->n, s_URL); + a = agfindnodeattr(agraphof(n), s_URL); if (a) +#ifndef WITH_CGRAPH job->selected_href = strdup_and_subst_obj(agxget(n, a->index), (void*)n); #else - a = agattr(g, AGNODE, s_href, NULL); - if (!a) - a = agattr(g, AGNODE, s_URL, NULL); - if (a) job->selected_href = strdup_and_subst_obj(agxget(n, a), (void*)n); #endif } @@ -227,17 +219,13 @@ static void gv_edge_state(GVJ_t *job, edge_t *e) } alist->argc = j; -#ifndef WITH_CGRAPH - a = agfindattr(e->head->graph->proto->e, s_href); + a = agfindedgeattr(agraphof(aghead(e)), s_href); if (!a) - a = agfindattr(e->head->graph->proto->e, s_URL); + a = agfindedgeattr(agraphof(aghead(e)), s_URL); if (a) +#ifndef WITH_CGRAPH job->selected_href = strdup_and_subst_obj(agxget(e, a->index), (void*)e); #else - a = agattr(agraphof(e), AGEDGE, s_href, NULL); - if (!a) - a = agattr(agraphof(e), AGEDGE, s_URL, NULL); - if (a) job->selected_href = strdup_and_subst_obj(agxget(e, a), (void*)e); #endif } @@ -343,39 +331,33 @@ static void gvevent_enter_obj(GVJ_t * job) #endif /* WITH_CGRAPH */ g = (graph_t*)obj; GD_gui_state(g) |= GUI_STATE_ACTIVE; -#ifndef WITH_CGRAPH - a = agfindattr(g->root, s_tooltip); + a = agfindgraphattr(agroot(g), s_tooltip); if (a) +#ifndef WITH_CGRAPH job->active_tooltip = strdup_and_subst_obj(agxget(g, a->index), obj); #else /* WITH_CGRAPH */ - a = agattr(agroot(g), AGRAPH, s_tooltip, NULL); - if (a) job->active_tooltip = strdup_and_subst_obj(agxget(g, a), obj); #endif /* WITH_CGRAPH */ break; case AGNODE: n = (node_t*)obj; ND_gui_state(n) |= GUI_STATE_ACTIVE; -#ifndef WITH_CGRAPH - a = agfindattr(n->graph->proto->n, s_tooltip); + a = agfindnodeattr(agraphof(n), s_tooltip); if (a) +#ifndef WITH_CGRAPH job->active_tooltip = strdup_and_subst_obj(agxget(n, a->index), obj); #else /* WITH_CGRAPH */ - a = agattr(agraphof(n), AGNODE, s_tooltip, NULL); - if (a) job->active_tooltip = strdup_and_subst_obj(agxget(n, a), obj); #endif /* WITH_CGRAPH */ break; case AGEDGE: e = (edge_t*)obj; ED_gui_state(e) |= GUI_STATE_ACTIVE; -#ifndef WITH_CGRAPH - a = agfindattr(e->head->graph->proto->e, s_tooltip); + a = agfindedgeattr(agraphof(aghead(e)), s_tooltip); if (a) +#ifndef WITH_CGRAPH job->active_tooltip = strdup_and_subst_obj(agxget(e, a->index), obj); #else /* WITH_CGRAPH */ - a = agattr(agraphof(e), AGEDGE, s_tooltip, NULL); - if (a) job->active_tooltip = strdup_and_subst_obj(agxget(e, a), obj); #endif /* WITH_CGRAPH */ break; diff --git a/lib/neatogen/neatoinit.c b/lib/neatogen/neatoinit.c index 01b36f0d2..7acbe2a98 100644 --- a/lib/neatogen/neatoinit.c +++ b/lib/neatogen/neatoinit.c @@ -144,13 +144,8 @@ static void neato_init_node_edge(graph_t * g) int nG = agnnodes(g); attrsym_t *N_pin; -#ifndef WITH_CGRAPH - N_pos = agfindattr(g->proto->n, "pos"); - N_pin = agfindattr(g->proto->n, "pin"); -#else - N_pos = agattr(g, AGNODE, "pos", 0); - N_pin = agattr(g, AGNODE, "pin", 0); -#endif + N_pos = agfindnodeattr(g, "pos"); + N_pin = agfindnodeattr(g, "pin"); for (n = agfstnode(g); n; n = agnxtnode(g, n)) { neato_init_node(n); @@ -424,11 +419,7 @@ static pos_edge nop_init_edges(Agraph_t * g) node_t *n; edge_t *e; int nedges = 0; -#ifndef WITH_CGRAPH - attrsym_t *E_pos = agfindattr(g->proto->e, "pos"); -#else - attrsym_t *E_pos = agattr(g, AGEDGE, "pos", NULL); -#endif + attrsym_t *E_pos = agfindedgeattr(g, "pos"); if (!E_pos || (Nop < 2)) return NoEdges; @@ -669,13 +660,8 @@ int init_nop(Agraph_t * g, int adjust) int i; node_t *np; pos_edge posEdges; /* How many edges have spline info */ -#ifndef WITH_CGRAPH - attrsym_t *G_lp = agfindattr(g, "lp"); - attrsym_t *G_bb = agfindattr(g, "bb"); -#else /* WITH_CGRAPH */ - attrsym_t *G_lp = agattr(g, AGRAPH, "lp", NULL); - attrsym_t *G_bb = agattr(g, AGRAPH, "bb", NULL); -#endif /* WITH_CGRAPH */ + attrsym_t *G_lp = agfindgraphattr(g, "lp"); + attrsym_t *G_bb = agfindgraphattr(g, "bb"); /* If G_bb not defined, define it */ if (!G_bb) @@ -733,13 +719,8 @@ static void neato_init_graph (Agraph_t * g) int outdim; setEdgeType (g, ET_LINE); -#ifndef WITH_CGRAPH - outdim = late_int(g, agfindattr(g, "dimen"), 2, 2); - GD_ndim(g->root) = late_int(g, agfindattr(g, "dim"), outdim, 2); -#else /* WITH_CGRAPH */ - outdim = late_int(g, agattr(g, AGRAPH, "dimen", NULL), 2, 2); - GD_ndim(g->root) = late_int(g, agattr(g, AGRAPH, "dim", NULL), outdim, 2); -#endif /* WITH_CGRAPH */ + outdim = late_int(g, agfindgraphattr(g, "dimen"), 2, 2); + GD_ndim(agroot(g)) = late_int(g, agfindgraphattr(g, "dim"), outdim, 2); Ndim = GD_ndim(g->root) = MIN(GD_ndim(g->root), MAXDIM); GD_odim(g->root) = MIN(outdim, Ndim); neato_init_node_edge(g); @@ -1222,11 +1203,7 @@ majorization(graph_t *mg, graph_t * g, int nv, int mode, int model, int dim, int #ifdef DIGCOLA if (mode != MODE_MAJOR) { -#ifndef WITH_CGRAPH - double lgap = late_double(g, agfindattr(g, "levelsgap"), 0.0, -MAXDOUBLE); -#else /* WITH_CGRAPH */ - double lgap = late_double(g, agattr(g, AGRAPH, "levelsgap", NULL), 0.0, -MAXDOUBLE); -#endif /* WITH_CGRAPH */ + double lgap = late_double(g, agfindgraphattr(g, "levelsgap"), 0.0, -MAXDOUBLE); if (mode == MODE_HIER) { stress_majorization_with_hierarchy(gp, nv, ne, coords, nodes, Ndim, (init == INIT_SELF), model, MaxIter, lgap);