From 6e818420cf02ad01d9c976b69d49fb794a661f5e Mon Sep 17 00:00:00 2001 From: John Ellson Date: Wed, 16 Oct 2013 19:18:05 -0400 Subject: [PATCH] remove remaining CGRAPH conditionals --- cmd/dot/Makefile.am | 14 +- cmd/dot/dot.c | 24 --- cmd/gvedit/Makefile.am | 8 +- cmd/gvedit/csettings.cpp | 31 ---- cmd/gvedit/main.cpp | 11 -- cmd/smyrna/smyrnadefs.h | 3 - cmd/tools/gvpack.c | 155 ------------------ configure.ac | 19 --- graphviz.spec.in | 13 +- lib/agraph/Makefile.am | 3 - lib/agutil/Makefile.am | 3 - lib/common/types.h.in | 5 +- lib/graph/Makefile.am | 3 - lib/gvc/libgvc.pc.in | 5 +- plugin/core/gvrender_core_vml.c | 4 - plugin/dot_layout/Makefile.am | 5 - plugin/visio/VisioRender.cpp | 4 - plugin/visio/VisioText.cpp | 22 --- tclpkg/gv/Makefile.am | 11 +- tclpkg/gv/gv.cpp | 281 -------------------------------- tclpkg/tcldot/Makefile.am | 12 +- tclpkg/tcldot/tcldot-edgecmd.c | 36 ---- tclpkg/tcldot/tcldot-graphcmd.c | 235 -------------------------- tclpkg/tcldot/tcldot-id.c | 3 - tclpkg/tcldot/tcldot-io.c | 93 ----------- tclpkg/tcldot/tcldot-nodecmd.c | 86 +--------- tclpkg/tcldot/tcldot-util.c | 154 ----------------- tclpkg/tcldot/tcldot.c | 174 -------------------- tclpkg/tcldot/tcldot.h | 23 --- 29 files changed, 14 insertions(+), 1426 deletions(-) diff --git a/cmd/dot/Makefile.am b/cmd/dot/Makefile.am index f93bfe735..c22b0109f 100644 --- a/cmd/dot/Makefile.am +++ b/cmd/dot/Makefile.am @@ -1,12 +1,6 @@ # $Id$ $Revision$ ## Process this file with automake to produce Makefile.in -if WITH_CGRAPH -GRAPH = cgraph -else -GRAPH = graph -endif - pdfdir = $(pkgdatadir)/doc/pdf linkedman = neato.1 twopi.1 fdp.1 circo.1 @@ -24,7 +18,7 @@ AM_CPPFLAGS = \ -I$(top_srcdir)/lib/common \ -I$(top_srcdir)/lib/gvc \ -I$(top_srcdir)/lib/pathplan \ - -I$(top_srcdir)/lib/$(GRAPH) \ + -I$(top_srcdir)/lib/cgraph \ -I$(top_srcdir)/lib/cdt if ENABLE_SHARED @@ -54,7 +48,7 @@ dot_SOURCES = dot.c no_builtins.c dot_CPPFLAGS = $(AM_CPPFLAGS) -DDEMAND_LOADING=1 dot_LDADD = \ $(top_builddir)/lib/gvc/libgvc.la \ - $(top_builddir)/lib/$(GRAPH)/lib$(GRAPH).la + $(top_builddir)/lib/cgraph/libcgraph.la install-data-hook: (cd $(DESTDIR)$(man1dir); for i in $(linkedman); do rm -f $$i; $(LN_S) dot.1 $$i; done;) @@ -89,7 +83,7 @@ dot_static_LDADD = \ $(top_builddir)/plugin/core/libgvplugin_core_C.la \ $(top_builddir)/lib/gvc/libgvc_C.la \ $(top_builddir)/lib/pathplan/libpathplan_C.la \ - $(top_builddir)/lib/$(GRAPH)/lib$(GRAPH)_C.la \ + $(top_builddir)/lib/cgraph/libcgraph_C.la \ $(top_builddir)/lib/xdot/libxdot_C.la \ $(top_builddir)/lib/cdt/libcdt_C.la \ $(PANGOCAIRO_LIBS) $(PANGOFT2_LIBS) $(GTS_LIBS) $(EXPAT_LIBS) $(Z_LIBS) $(LIBGEN_LIBS) $(SOCKET_LIBS) $(IPSEPCOLA_LIBS) $(MATH_LIBS) @@ -102,7 +96,7 @@ dot_builtins_LDADD = \ $(top_builddir)/plugin/core/libgvplugin_core.la \ $(top_builddir)/lib/gvc/libgvc.la \ $(top_builddir)/lib/pathplan/libpathplan.la \ - $(top_builddir)/lib/$(GRAPH)/lib$(GRAPH).la \ + $(top_builddir)/lib/cgraph/libcgraph.la \ $(top_builddir)/lib/xdot/libxdot.la \ $(top_builddir)/lib/cdt/libcdt.la \ $(GTS_LIBS) $(EXPAT_LIBS) $(Z_LIBS) $(LIBGEN_LIBS) $(SOCKET_LIBS) $(IPSEPCOLA_LIBS) $(MATH_LIBS) diff --git a/cmd/dot/dot.c b/cmd/dot/dot.c index 1e23ab423..5b8b61675 100644 --- a/cmd/dot/dot.c +++ b/cmd/dot/dot.c @@ -26,11 +26,7 @@ __declspec(dllimport) boolean MemTest; __declspec(dllimport) int GvExitOnUsage; /*gvc.lib cgraph.lib*/ -#ifdef WITH_CGRAPH #pragma comment( lib, "cgraph.lib" ) -#else - #pragma comment( lib, "graph.lib" ) -#endif #pragma comment( lib, "gvc.lib" ) #else /* not WIN32_DLL */ #include "globals.h" @@ -132,44 +128,24 @@ static graph_t *create_test_graph(void) char name[10]; /* Create a new graph */ -#ifndef WITH_CGRAPH - aginit(); - agsetiodisc(NULL, gvfwrite, gvferror); - g = agopen("new_graph", AGDIGRAPH); -#else /* WITH_CGRAPH */ g = agopen("new_graph", Agdirected,NIL(Agdisc_t *)); -#endif /* WITH_CGRAPH */ /* Add nodes */ for (j = 0; j < NUMNODES; j++) { sprintf(name, "%d", j); -#ifndef WITH_CGRAPH - node[j] = agnode(g, name); -#else /* WITH_CGRAPH */ node[j] = agnode(g, name, 1); agbindrec(node[j], "Agnodeinfo_t", sizeof(Agnodeinfo_t), TRUE); //node custom data -#endif /* WITH_CGRAPH */ } /* Connect nodes */ for (j = 0; j < NUMNODES; j++) { for (k = j + 1; k < NUMNODES; k++) { -#ifndef WITH_CGRAPH - agedge(g, node[j], node[k]); -#else /* WITH_CGRAPH */ e = agedge(g, node[j], node[k], NULL, 1); agbindrec(e, "Agedgeinfo_t", sizeof(Agedgeinfo_t), TRUE); //edge custom data -#endif /* WITH_CGRAPH */ } } - -#ifndef WITH_CGRAPH - sg = agsubg (g, "cluster1"); - aginsert (sg, node[0]); -#else /* WITH_CGRAPH */ sg = agsubg (g, "cluster1", 1); agsubnode (sg, node[0], 1); -#endif /* WITH_CGRAPH */ return g; } diff --git a/cmd/gvedit/Makefile.am b/cmd/gvedit/Makefile.am index 3467f0cdd..9c3397758 100644 --- a/cmd/gvedit/Makefile.am +++ b/cmd/gvedit/Makefile.am @@ -1,12 +1,6 @@ # $Id$ $Revision$ ## Process this file with automake to produce Makefile.in -if WITH_CGRAPH -GRAPH = cgraph -else -GRAPH = graph -endif - SUBDIRS = ui images pdfdir = $(pkgdatadir)/doc/pdf @@ -23,7 +17,7 @@ AM_CPPFLAGS = \ -I$(top_srcdir)/lib/common \ -I$(top_srcdir)/lib/gvc \ -I$(top_srcdir)/lib/pathplan \ - -I$(top_srcdir)/lib/$(GRAPH) \ + -I$(top_srcdir)/lib/cgraph \ -I$(top_srcdir)/lib/cdt gvedit_CPPFLAGS = \ diff --git a/cmd/gvedit/csettings.cpp b/cmd/gvedit/csettings.cpp index 6f29487de..fbac3cf6a 100644 --- a/cmd/gvedit/csettings.cpp +++ b/cmd/gvedit/csettings.cpp @@ -78,32 +78,6 @@ QString stripFileExtension(QString fileName) return fileName.left(idx); } -#ifndef WITH_CGRAPH -static char* -graph_reader(char *str, int num, FILE * stream) //helper function to load / parse graphs from tstring -{ - if (num == 0) - return str; - const char *ptr; - char *optr; - char c; - int l; - rdr_t *s = (rdr_t *) stream; - if (s->cur >= s->len) - return NULL; - l = 0; - ptr = s->data + s->cur; - optr = str; - do { - *optr++ = c = *ptr++; - l++; - } while (c && (c != '\n') && (l < num - 1)); - *optr = '\0'; - s->cur += l; - return str; -} -#endif - CFrmSettings::CFrmSettings() { this->gvc = gvContext(); @@ -318,12 +292,7 @@ bool CFrmSettings::createLayout() rdr.data = bytes.constData(); rdr.len = strlen(rdr.data); rdr.cur = 0; -#ifdef WITH_CGRAPH graph = agmemread(rdr.data); -#else - graph = agread_usergets((FILE *) & rdr, (gets_f) graph_reader); - /* graph=agread_usergets(reinterpret_cast(this),(gets_f)graph_reader); */ -#endif if (!graph) return false; if (agerrors()) { diff --git a/cmd/gvedit/main.cpp b/cmd/gvedit/main.cpp index 0d54ba6aa..13b68a386 100644 --- a/cmd/gvedit/main.cpp +++ b/cmd/gvedit/main.cpp @@ -35,18 +35,7 @@ #ifdef WIN32 /*gvc.lib cgraph.lib*/ -#ifdef WITH_CGRAPH #pragma comment( lib, "cgraph.lib" ) -#else -#pragma comment( lib, "graph.lib" ) -#pragma comment( lib, "gvc.lib" ) -#pragma comment( lib, "glib-2.0.lib" ) -#pragma comment( lib, "pango-1.0.lib" ) -#pragma comment( lib, "pangocairo-1.0.lib" ) -#pragma comment( lib, "cairo.lib" ) -#pragma comment( lib, "gobject-2.0.lib" ) - -#endif #pragma comment( lib, "gvc.lib" ) #pragma comment( lib, "ingraphs.lib" ) diff --git a/cmd/smyrna/smyrnadefs.h b/cmd/smyrna/smyrnadefs.h index 457538ccc..1e86d8466 100644 --- a/cmd/smyrna/smyrnadefs.h +++ b/cmd/smyrna/smyrnadefs.h @@ -39,9 +39,6 @@ extern "C" { #endif -#define WITH_CGRAPH 1 - - #ifdef WIN32 //this is needed on WIN32 to get libglade see the callback #define _BB __declspec(dllexport) #else diff --git a/cmd/tools/gvpack.c b/cmd/tools/gvpack.c index 85ad7b81e..fc1ef4776 100644 --- a/cmd/tools/gvpack.c +++ b/cmd/tools/gvpack.c @@ -35,17 +35,9 @@ #include "ingraphs.h" #include "pack.h" -#ifndef WITH_CGRAPH -extern Agdict_t *agdictof(void *); -#endif - #ifdef WIN32 /*dependencies*/ -#ifdef WITH_CGRAPH #pragma comment( lib, "cgraph.lib" ) -#else - #pragma comment( lib, "graph.lib" ) -#endif #pragma comment( lib, "gvc.lib" ) #pragma comment( lib, "ingraphs.lib" ) #pragma comment( lib, "neatogen.lib" ) @@ -56,8 +48,6 @@ extern Agdict_t *agdictof(void *); #pragma comment( lib, "glib-2.0.lib" ) #pragma comment( lib, "cdt.lib" ) #pragma comment( lib, "gvplugin_neato_layout.lib" ) - - #endif @@ -86,11 +76,7 @@ static int verbose = 0; static char **myFiles = 0; static int nGraphs = 0; /* Guess as to no. of graphs */ static FILE *outfp; /* output; stdout by default */ -#ifndef WITH_CGRAPH -static int kind; /* type of graph */ -#else static Agdesc_t kind; /* type of graph */ -#endif static int G_cnt; /* No. of -G arguments */ static int G_sz; /* Storage size for -G arguments */ static attr_t *G_args; /* Storage for -G arguments */ @@ -182,7 +168,6 @@ static int setUInt(unsigned int *v, char *arg) return 0; } -#ifdef WITH_CGRAPH static Agsym_t *agraphattr(Agraph_t *g, char *name, char *value) { return agattr(g, AGRAPH, name, value); @@ -198,8 +183,6 @@ static Agsym_t *agedgeattr(Agraph_t *g, char *name, char *value) return agattr(g, AGEDGE, name, value); } -#endif - /* init: */ static void init(int argc, char *argv[], pack_info* pinfo) @@ -208,9 +191,6 @@ static void init(int argc, char *argv[], pack_info* pinfo) char buf[BUFSIZ]; char* bp; -#ifndef WITH_CGRAPH - aginit(); -#endif agnodeattr(NULL, "label", NODENAME_ESC); pinfo->mode = l_clust; pinfo->margin = CL_OFFSET; @@ -319,11 +299,9 @@ static void init_graph(Agraph_t * g, boolean fill, GVC_t* gvc) node_t *n; edge_t *e; -#ifdef WITH_CGRAPH aginit (g, AGRAPH, "Agraphinfo_t", sizeof(Agraphinfo_t), TRUE); aginit (g, AGNODE, "Agnodeinfo_t", sizeof(Agnodeinfo_t), TRUE); aginit (g, AGEDGE, "Agedgeinfo_t", sizeof(Agedgeinfo_t), TRUE); -#endif GD_gvc(g) = gvc; graph_init(g, FALSE); d = late_int(g, agfindgraphattr(g, "dim"), 2, 2); @@ -359,7 +337,6 @@ static void init_graph(Agraph_t * g, boolean fill, GVC_t* gvc) * Copy all attributes from old object to new. Assume * attributes have been initialized. */ -#ifdef WITH_CGRAPH static void cloneDfltAttrs(Agraph_t *old, Agraph_t *new, int kind) { Agsym_t *a; @@ -387,19 +364,6 @@ static void cloneAttrs(void *old, void *new) agset(new, a->name, s); } } -#else -static void cloneAttrs(void *old, void *new) -{ - int j; - Agsym_t *a; - Agdict_t *dict = agdictof(old); - - for (j = 0; j < dtsize(dict->dict); j++) { - a = dict->list[j]; - agset(new, a->name, agxget(old, a->index)); - } -} -#endif /* cloneEdge: * Note that here, and in cloneNode and cloneCluster, @@ -469,7 +433,6 @@ static Dtdisc_t attrdisc = { * objp. If the attribute has already been defined and * has a different default, set default to "". */ -#ifdef WITH_CGRAPH static void fillDict(Dt_t * newdict, Agraph_t* g, int kind) { Agsym_t *a; @@ -490,31 +453,6 @@ static void fillDict(Dt_t * newdict, Agraph_t* g, int kind) rv->value = ""; } } -#else -static void fillDict(Dt_t * newdict, void *objp) -{ - int j; - Agsym_t *a; - Agdict_t *olddict = agdictof(objp); - char *name; - char *value; - attr_t *rv; - - for (j = 0; j < dtsize(olddict->dict); j++) { - a = olddict->list[j]; - name = a->name; - value = agxget(objp, a->index); - rv = (attr_t *) dtmatch(newdict, name); - if (!rv) { - rv = NEW(attr_t); - rv->name = name; - rv->value = value; - dtinsert(newdict, rv); - } else if (strcmp(value, rv->value)) - rv->value = ""; - } -} -#endif /* fillGraph: * Use all the name-value entries in the dictionary d to define @@ -549,15 +487,9 @@ static void initAttrs(Agraph_t * root, Agraph_t ** gs, int cnt) for (i = 0; i < cnt; i++) { g = gs[i]; -#ifdef WITH_CGRAPH fillDict(g_attrs, g, AGRAPH); fillDict(n_attrs, g, AGNODE); fillDict(e_attrs, g, AGEDGE); -#else - fillDict(g_attrs, g); - fillDict(n_attrs, g->proto->n); - fillDict(e_attrs, g->proto->e); -#endif } fillGraph(root, g_attrs, agraphattr); @@ -574,13 +506,8 @@ static void initAttrs(Agraph_t * root, Agraph_t ** gs, int cnt) static void cloneGraphAttr(Agraph_t * g, Agraph_t * ng) { cloneAttrs(g, ng); -#ifdef WITH_CGRAPH cloneDfltAttrs(g, ng, AGNODE); cloneDfltAttrs(g, ng, AGEDGE); -#else - cloneAttrs(g->proto->n, ng->proto->n); - cloneAttrs(g->proto->e, ng->proto->e); -#endif } #ifdef UNIMPL @@ -653,11 +580,6 @@ static char *xName(Dt_t * names, char *oldname) static void cloneSubg(Agraph_t * g, Agraph_t * ng, Agsym_t * G_bb, Dt_t * gnames) { -#ifndef WITH_CGRAPH - graph_t *mg; - edge_t *me; - node_t *mn; -#endif node_t *n; node_t *nn; edge_t *e; @@ -669,24 +591,12 @@ cloneSubg(Agraph_t * g, Agraph_t * ng, Agsym_t * G_bb, Dt_t * gnames) cloneGraphAttr(g, ng); if (doPack) -#ifdef WITH_CGRAPH agxset(ng, G_bb, ""); /* Unset all subgraph bb */ -#else - agxset(ng, G_bb->index, ""); /* Unset all subgraph bb */ -#endif /* clone subgraphs */ -#ifdef WITH_CGRAPH for (subg = agfstsubg (g); subg; subg = agfstsubg (subg)) { nsubg = agsubg(ng, xName(gnames, agnameof(subg)), 1); agbindrec (nsubg, "Agraphinfo_t", sizeof(Agraphinfo_t), TRUE); -#else - mg = g->meta_node->graph; - for (me = agfstout(mg, g->meta_node); me; me = agnxtout(mg, me)) { - mn = aghead(me); - subg = agusergraph(mn); - nsubg = agsubg(ng, xName(gnames, agnameof(subg))); -#endif cloneSubg(subg, nsubg, G_bb, gnames); /* if subgraphs are clusters, point to the new * one so we can find it later. @@ -698,12 +608,7 @@ cloneSubg(Agraph_t * g, Agraph_t * ng, Agsym_t * G_bb, Dt_t * gnames) /* add remaining nodes */ for (n = agfstnode(g); n; n = agnxtnode(g, n)) { nn = NEWNODE(n); -#ifndef WITH_CGRAPH - if (!agfindnode(ng, agnameof(nn))) - aginsert(ng, nn); -#else agsubnode(ng, nn, 1); -#endif } /* add remaining edges. libgraph doesn't provide a way to find @@ -715,12 +620,8 @@ cloneSubg(Agraph_t * g, Agraph_t * ng, Agsym_t * G_bb, Dt_t * gnames) continue; nt = NEWNODE(agtail(e)); nh = NEWNODE(aghead(e)); -#ifndef WITH_CGRAPH - ne = agedge(ng, nt, nh); -#else ne = agedge(ng, nt, nh, NULL, 1); agbindrec (ne, "Agedgeinfo_t", sizeof(Agedgeinfo_t), TRUE); -#endif cloneEdge(e, ne); MARK(e); } @@ -781,11 +682,7 @@ static Agraph_t *cloneGraph(Agraph_t ** gs, int cnt, GVC_t * gvc) if (verbose) fprintf(stderr, "Creating clone graph\n"); -#ifndef WITH_CGRAPH - root = agopen(gname, kind); -#else root = agopen(gname, kind, &AgDefaultDisc); -#endif initAttrs(root, gs, cnt); G_bb = agfindgraphattr(root, "bb"); if (doPack) assert(G_bb); @@ -794,15 +691,9 @@ static Agraph_t *cloneGraph(Agraph_t ** gs, int cnt, GVC_t * gvc) for (i = 0; i < G_cnt; i++) { rv = agfindgraphattr(root, G_args[i].name); if (rv) -#ifndef WITH_CGRAPH - agxset(root, rv->index, G_args[i].value); - else - agraphattr(root, G_args[i].name, G_args[i].value); -#else agxset(root, rv, G_args[i].value); else agattr(root, AGRAPH, G_args[i].name, G_args[i].value); -#endif } /* do common initialization. This will handle root's label. */ @@ -826,23 +717,15 @@ static Agraph_t *cloneGraph(Agraph_t ** gs, int cnt, GVC_t * gvc) fprintf(stderr, "Some nodes will be renamed.\n"); doWarn = FALSE; } -#ifndef WITH_CGRAPH - np = agnode(root, xName(nnames, agnameof(n))); -#else np = agnode(root, xName(nnames, agnameof(n)), 1); agbindrec (np, "Agnodeinfo_t", sizeof(Agnodeinfo_t), TRUE); -#endif ND_alg(n) = np; cloneNode(n, np); } /* wrap the clone of g in a subgraph of root */ -#ifndef WITH_CGRAPH - subg = agsubg(root, xName(gnames, agnameof(g))); -#else subg = agsubg(root, xName(gnames, agnameof(g)), 1); agbindrec (subg, "Agraphinfo_t", sizeof(Agraphinfo_t), TRUE); -#endif cloneSubg(g, subg, G_bb, gnames); } dtclose(gnames); @@ -867,17 +750,10 @@ static Agraph_t *cloneGraph(Agraph_t ** gs, int cnt, GVC_t * gvc) return root; } -#ifdef WITH_CGRAPH static Agraph_t *gread(FILE * fp) { return agread(fp, (Agdisc_t *) 0); } -#else -static Agraph_t *gread(FILE * fp) -{ - return agread(fp); -} -#endif /* readGraphs: * Read input, parse the graphs, use init_nop (neato -n) to @@ -914,18 +790,6 @@ static Agraph_t **readGraphs(int *cp, GVC_t* gvc) sz += nGraphs; gs = ALLOC(sz, gs, Agraph_t *); } -#ifndef WITH_CGRAPH - if (kindUnset) { - kindUnset = 0; - kind = g->kind; - } - else if ((kind & AGFLAG_DIRECTED) != AG_IS_DIRECTED(g)) { - fprintf(stderr, - "Error: all graphs must be directed or undirected\n"); - exit(1); - } else if (!AG_IS_STRICT(g)) - kind = g->kind; -#else if (kindUnset) { kindUnset = 0; kind = g->desc; @@ -936,7 +800,6 @@ static Agraph_t **readGraphs(int *cp, GVC_t* gvc) exit(1); } else if (!agisstrict(g)) kind = g->desc; -#endif init_graph(g, doPack, gvc); gs[cnt++] = g; } @@ -983,23 +846,6 @@ void dump(Agraph_t * g) } } -#ifndef WITH_CGRAPH -void dumps(Agraph_t * g) -{ - graph_t *subg; - graph_t *mg; - edge_t *me; - node_t *mn; - - mg = g->meta_node->graph; - for (me = agfstout(mg, g->meta_node); me; me = agnxtout(mg, me)) { - mn = aghead(me); - subg = agusergraph(mn); - dump(subg); - fprintf(stderr, "====\n"); - } -} -#else void dumps(Agraph_t * g) { graph_t *subg; @@ -1010,7 +856,6 @@ void dumps(Agraph_t * g) } } #endif -#endif int main(int argc, char *argv[]) { diff --git a/configure.ac b/configure.ac index c81caee34..91d6a6e29 100644 --- a/configure.ac +++ b/configure.ac @@ -2952,23 +2952,6 @@ else fi AM_CONDITIONAL(WITH_SMYRNA, [test "x$use_smyrna" = "xYes"]) -dnl ----------------------------------- -dnl CGRAPH - -AC_ARG_WITH(cgraph, - [AS_HELP_STRING([--with-cgraph=yes],[Use CGRAPH library])], - [], [with_cgraph=yes]) - -if test "x$with_cgraph" != "xyes"; then - use_cgraph="No (disabled)" - use_graph="Yes" -else - use_cgraph="Yes" - use_graph="No (disabled deprecated)" - AC_DEFINE_UNQUOTED(WITH_CGRAPH,1,[Define if you want CGRAPH]) -fi -AM_CONDITIONAL(WITH_CGRAPH, [test "x$use_cgraph" = "xYes"]) - dnl ----------------------------------- dnl ORTHO @@ -3150,8 +3133,6 @@ AC_CONFIG_FILES(Makefile lib/Makefile lib/cdt/Makefile lib/cdt/libcdt.pc - lib/graph/Makefile - lib/graph/libgraph.pc lib/cgraph/Makefile lib/cgraph/libcgraph.pc lib/rbtree/Makefile diff --git a/graphviz.spec.in b/graphviz.spec.in index 2cc57b908..0d7930378 100644 --- a/graphviz.spec.in +++ b/graphviz.spec.in @@ -30,7 +30,7 @@ Prefix: /usr # Available features are: # SHARP GHOSTSCRIPT GUILE _IO JAVA LUA OCAML ORTHO PERL PHP # PYTHON RUBY R_LANG TCL IPSEPCOLA MYLIBGD PANGOCAIRO RSVG -# GTK GLITZ SMYRNA DEVIL MING GDK_PIXBUF _QT WEBP CGRAPH +# GTK GLITZ SMYRNA DEVIL MING GDK_PIXBUF _QT WEBP # SuSE uses a different mechanism to generate BuildRequires # norootforbuild @@ -43,7 +43,6 @@ BuildRequires: /bin/ksh bison m4 flex swig tk tcl >= 8.3 freetype-devel >= 2 #-- All platforms %define __X 1 -%define CGRAPH 1 #-- Red Hat Enterprise Linux (also Centos) specific Build Requirements %if 0%{?rhel} @@ -274,9 +273,6 @@ Graphviz core libs %defattr(-,root,root,-) %{_libdir}/libcdt.so.* %{_libdir}/libcgraph.so.* -%if ! 0%{?CGRAPH} -%{_libdir}/libgraph.so.* -%endif %{_libdir}/libgvc.so.* %{_libdir}/libgvpr.so.* %{_libdir}/libpathplan.so.* @@ -766,13 +762,7 @@ This package contains development files for graphviz-libs. %{_libdir}/libcgraph.so %{_mandir}/man3/cgraph.3.* %{_libdir}/pkgconfig/libcgraph.pc -%if ! 0%{?CGRAPH} -%{_libdir}/libgraph.so -%{_mandir}/man3/graph.3.* -%{_libdir}/pkgconfig/libgraph.pc -%else %exclude %{_mandir}/man3/graph.3.* -%endif %{_libdir}/libgvc.so %{_mandir}/man3/gvc.3.* %{_libdir}/pkgconfig/libgvc.pc @@ -860,7 +850,6 @@ CFLAGS="$RPM_OPT_FLAGS" \ --enable-r%{!?R_LANG:=no} \ --enable-ruby%{!?RUBY:=no} \ --enable-tcl%{!?TCL:=no} \ - --with%{!?CGRAPH:out}-cgraph \ --with%{!?DEVIL:out}-devil \ --with%{!?WEBP:out}-webp \ --with%{!?GDK_PIXBUF:out}-gdk-pixbuf \ diff --git a/lib/agraph/Makefile.am b/lib/agraph/Makefile.am index fe6ed34a5..e1c3fef06 100644 --- a/lib/agraph/Makefile.am +++ b/lib/agraph/Makefile.am @@ -10,8 +10,6 @@ AM_CPPFLAGS = \ -I$(top_srcdir) \ -I$(top_srcdir)/lib/cdt -if WITH_CGRAPH -else pkginclude_HEADERS = agraph.h noinst_HEADERS = aghdr.h malloc.h vmstub.h grammar.h noinst_LTLIBRARIES = libagraph_C.la @@ -19,7 +17,6 @@ lib_LTLIBRARIES = libagraph.la pkgconfig_DATA = libagraph.pc man_MANS = agraph.3 pdf_DATA = agraph.3.pdf -endif libagraph_C_la_SOURCES = agerror.c apply.c attr.c \ edge.c flatten.c grammar.y graph.c id.c imap.c io.c \ diff --git a/lib/agutil/Makefile.am b/lib/agutil/Makefile.am index 1b0b837d0..cbf6f0d00 100644 --- a/lib/agutil/Makefile.am +++ b/lib/agutil/Makefile.am @@ -6,11 +6,8 @@ AM_CPPFLAGS = \ -I$(top_srcdir)/lib/agraph \ -I$(top_srcdir)/lib/cdt -if WITH_CGRAPH -else noinst_HEADERS = agutil.h noinst_LTLIBRARIES = libagutil_C.la -endif libagutil_C_la_SOURCES = dynattr.c nodeq.c agutil.h diff --git a/lib/common/types.h.in b/lib/common/types.h.in index c1502ef6f..36999b742 100644 --- a/lib/common/types.h.in +++ b/lib/common/types.h.in @@ -14,9 +14,6 @@ #ifndef GV_TYPES_H #define GV_TYPES_H -/* Define if you want CGRAPH */ -#undef WITH_CGRAPH - #include #include #include @@ -36,6 +33,7 @@ typedef unsigned char boolean; #include "gvcext.h" #include "pathgeom.h" #include "textpara.h" +#include "cgraph.h" #ifdef __cplusplus extern "C" { @@ -557,7 +555,6 @@ typedef enum {NATIVEFONTS,PSFONTS,SVGFONTS} fontname_kind; #define ED_dist(e) (((Agedgeinfo_t*)AGDATA(e))->dist) #define ED_weight(e) (((Agedgeinfo_t*)AGDATA(e))->weight) -#include "cgraph.h" #define ag_xget(x,a) agxget(x,a) #define SET_RANKDIR(g,rd) (GD_rankdir2(g) = rd) #define agfindedge(g,t,h) (agedge(g,t,h,NULL,0)) diff --git a/lib/graph/Makefile.am b/lib/graph/Makefile.am index 4cb22e74c..19bef1692 100644 --- a/lib/graph/Makefile.am +++ b/lib/graph/Makefile.am @@ -11,15 +11,12 @@ AM_CPPFLAGS = \ -I$(top_srcdir)/lib/cdt man_MANS = graph.3 -if WITH_CGRAPH -else pkginclude_HEADERS = graph.h noinst_HEADERS = libgraph.h triefa.h parser.h agxbuf.h noinst_LTLIBRARIES = libgraph_C.la lib_LTLIBRARIES = libgraph.la pkgconfig_DATA = libgraph.pc pdf_DATA = graph.3.pdf -endif libgraph_C_la_SOURCES = \ attribs.c agxbuf.c edge.c graph.c graphio.c lexer.c \ diff --git a/lib/gvc/libgvc.pc.in b/lib/gvc/libgvc.pc.in index de44d8b14..4ac59f951 100644 --- a/lib/gvc/libgvc.pc.in +++ b/lib/gvc/libgvc.pc.in @@ -3,13 +3,10 @@ exec_prefix=@exec_prefix@ libdir=@libdir@ includedir=@includedir@/@PACKAGE@ plugins=@GVPLUGIN_VERSION@ -@WITH_CGRAPH_FALSE@GRAPH = graph -@WITH_CGRAPH_TRUE@GRAPH = cgraph - Name: libgvc Description: The GraphVizContext library Version: @VERSION@ -Libs: -L${libdir} -lgvc -l${GRAPH} -lcdt +Libs: -L${libdir} -lgvc -lcgraph -lcdt Cflags: -I${includedir} diff --git a/plugin/core/gvrender_core_vml.c b/plugin/core/gvrender_core_vml.c index 69d191c32..63580edf4 100644 --- a/plugin/core/gvrender_core_vml.c +++ b/plugin/core/gvrender_core_vml.c @@ -264,11 +264,7 @@ static void vml_begin_graph(GVJ_t * job) gvputs(job, "\n"); -#ifndef WITH_CGRAPH - name = obj->u.g->name; -#else name = agnameof(obj->u.g); -#endif if (name[0]) { gvputs(job, ""); gvputs(job, html_string(name)); diff --git a/plugin/dot_layout/Makefile.am b/plugin/dot_layout/Makefile.am index c11f604b0..01622f69d 100644 --- a/plugin/dot_layout/Makefile.am +++ b/plugin/dot_layout/Makefile.am @@ -21,13 +21,8 @@ endif libgvplugin_dot_layout_C_la_SOURCES = \ gvplugin_dot_layout.c \ gvlayout_dot_layout.c -if WITH_CGRAPH libgvplugin_dot_layout_C_la_LIBADD = \ $(top_builddir)/lib/dotgen/libdotgen_C.la -else -libgvplugin_dot_layout_C_la_LIBADD = \ - $(top_builddir)/lib/dotgen/libdotgen_C.la -endif libgvplugin_dot_layout_la_LDFLAGS = -version-info $(GVPLUGIN_VERSION_INFO) libgvplugin_dot_layout_la_SOURCES = $(libgvplugin_dot_layout_C_la_SOURCES) diff --git a/plugin/visio/VisioRender.cpp b/plugin/visio/VisioRender.cpp index 25b7df1d7..bc70bfad4 100644 --- a/plugin/visio/VisioRender.cpp +++ b/plugin/visio/VisioRender.cpp @@ -204,11 +204,7 @@ namespace Visio _graphics[0], beginId == _nodeIds.end() ? 0 : beginId->second, endId == _nodeIds.end() ? 0 : endId->second, -#ifdef WITH_CGRAPH EDGE_TYPE(agroot(edge)))) -#else - EDGE_TYPE(edge->head->graph->root))) -#endif firstConnector = false; else PrintOuterShape(job, *nextGraphic); diff --git a/plugin/visio/VisioText.cpp b/plugin/visio/VisioText.cpp index 1647ef597..54731235c 100644 --- a/plugin/visio/VisioText.cpp +++ b/plugin/visio/VisioText.cpp @@ -19,9 +19,7 @@ #include "gvcjob.h" #include "gvio.h" -#ifdef WITH_CGRAPH #include <string.h> -#endif extern "C" char *xml_string(char* str); @@ -59,22 +57,14 @@ namespace Visio Run::Run(boxf bounds, char* text): _bounds(bounds), -#ifdef WITH_CGRAPH _text(strdup(text)) /* copy text */ -#else - _text(agstrdup(text)) /* copy text */ -#endif { } Run::~Run() { /* since we copied, we need to free */ -#ifdef WITH_CGRAPH free(_text); -#else - agstrfree(_text); -#endif } boxf Run::GetBounds() const @@ -171,29 +161,17 @@ namespace Visio } Hyperlink::Hyperlink(char* description, char* address, char* frame): -#ifdef WITH_CGRAPH _description(strdup(description)), _address(strdup(address)), _frame(strdup(frame)) -#else - _description(agstrdup(description)), - _address(agstrdup(address)), - _frame(agstrdup(frame)) -#endif { } Hyperlink::~Hyperlink() { -#ifdef WITH_CGRAPH free(_description); free(_address); free(_frame); -#else - agstrfree(_description); - agstrfree(_address); - agstrfree(_frame); -#endif } /* output the hyperlink */ diff --git a/tclpkg/gv/Makefile.am b/tclpkg/gv/Makefile.am index 2577e67cb..61173a9f0 100644 --- a/tclpkg/gv/Makefile.am +++ b/tclpkg/gv/Makefile.am @@ -3,20 +3,13 @@ SUBDIRS = demo -if WITH_CGRAPH -GRAPH = cgraph -DEFS += -DWITH_CGRAPH -else -GRAPH = graph -endif - pdfdir = $(pkgdatadir)/doc/pdf AM_CPPFLAGS = \ -I$(top_srcdir) \ -I$(top_srcdir)/lib/gvc \ -I$(top_srcdir)/lib/common \ - -I$(top_srcdir)/lib/$(GRAPH) \ + -I$(top_srcdir)/lib/cgraph \ -I$(top_srcdir)/lib/cdt \ -I$(top_srcdir)/lib/pathplan @@ -24,7 +17,7 @@ LIBS = -lc BASESOURCES = gv.cpp gv.i gv_builtins.c BASELIBS = $(top_builddir)/lib/gvc/libgvc.la \ - $(top_builddir)/lib/$(GRAPH)/lib$(GRAPH).la \ + $(top_builddir)/lib/cgraph/libcgraph.la \ $(top_builddir)/lib/cdt/libcdt.la BASECPPFLAGS = $(AM_CPPFLAGS) -DDEMAND_LOADING=1 diff --git a/tclpkg/gv/gv.cpp b/tclpkg/gv/gv.cpp index 14706d421..a8459f843 100644 --- a/tclpkg/gv/gv.cpp +++ b/tclpkg/gv/gv.cpp @@ -20,12 +20,10 @@ extern void gv_string_writer_init(GVC_t *gvc); extern void gv_channel_writer_init(GVC_t *gvc); } -#ifdef WITH_CGRAPH #define agfindattr(x,s) agattrsym(x,s) #define agraphattr(g,n,s) agattr(g,AGRAPH,n,s) #define agnodeattr(g,n,s) agattr(g,AGNODE,n,s) #define agedgeattr(g,n,s) agattr(g,AGEDGE,n,s) -#endif static char emptystring[] = {'\0'}; @@ -40,44 +38,28 @@ Agraph_t *graph(char *name) { if (!gvc) gv_init(); -#ifdef WITH_CGRAPH return agopen(name, Agundirected, 0); -#else - return agopen(name, AGRAPH); -#endif } Agraph_t *digraph(char *name) { if (!gvc) gv_init(); -#ifdef WITH_CGRAPH return agopen(name, Agdirected, 0); -#else - return agopen(name, AGDIGRAPH); -#endif } Agraph_t *strictgraph(char *name) { if (!gvc) gv_init(); -#ifdef WITH_CGRAPH return agopen(name, Agstrictundirected, 0); -#else - return agopen(name, AGRAPHSTRICT); -#endif } Agraph_t *strictdigraph(char *name) { if (!gvc) gv_init(); -#ifdef WITH_CGRAPH return agopen(name, Agstrictdirected, 0); -#else - return agopen(name, AGDIGRAPHSTRICT); -#endif } Agraph_t *readstring(char *string) @@ -91,11 +73,7 @@ Agraph_t *read(FILE *f) { if (!gvc) gv_init(); -#ifdef WITH_CGRAPH return agread(f, NULL); -#else - return agread(f); -#endif } Agraph_t *read(const char *filename) @@ -108,11 +86,7 @@ Agraph_t *read(const char *filename) return NULL; if (!gvc) gv_init(); -#ifdef WITH_CGRAPH g = agread(f, NULL); -#else - g = agread(f); -#endif fclose(f); return g; } @@ -122,63 +96,36 @@ Agraph_t *graph(Agraph_t *g, char *name) { if (!gvc) gv_init(); -#ifdef WITH_CGRAPH return agsubg(g, name, 1); -#else - return agsubg(g, name); -#endif } Agnode_t *node(Agraph_t *g, char *name) { if (!gvc) return NULL; -#ifdef WITH_CGRAPH return agnode(g, name, 1); -#else - // creating a protonode is not permitted - if (name[0] == '\001' && strcmp (name, "\001proto") == 0) - return NULL; - return agnode(g, name); -#endif } Agedge_t *edge(Agnode_t *t, Agnode_t *h) { if (!gvc || !t || !h) return NULL; -#ifdef WITH_CGRAPH // edges from/to the protonode are not permitted if (AGTYPE(t) == AGRAPH || AGTYPE(h) == AGRAPH) return NULL; return agedge(agraphof(t), t, h, NULL, 1); -#else - // edges from/to the protonode are not permitted - if ((agnameof(t)[0] == '\001' && strcmp (agnameof(t), "\001proto") == 0) - || (agnameof(h)[0] == '\001' && strcmp (agnameof(h), "\001proto") == 0)) - return NULL; - return agedge(t->graph, t, h); -#endif } // induce tail if necessary Agedge_t *edge(char *tname, Agnode_t *h) { -#ifdef WITH_CGRAPH return edge(node(agraphof(h), tname), h); -#else - return edge(node(h->graph, tname), h); -#endif } // induce head if necessary Agedge_t *edge(Agnode_t *t, char *hname) { -#ifdef WITH_CGRAPH return edge(t, node(agraphof(t), hname)); -#else - return edge(t, node(t->graph, hname)); -#endif } // induce tail/head if necessary @@ -195,11 +142,7 @@ static char* myagxget(void *obj, Agsym_t *a) if (!obj || !a) return emptystring; -#ifndef WITH_CGRAPH - val = agxget(obj, a->index); -#else val = agxget(obj, a); -#endif if (!val) return emptystring; if (a->name[0] == 'l' && strcmp(a->name, "label") == 0 && aghtmlstr(val)) { @@ -236,19 +179,11 @@ static void myagxset(void *obj, Agsym_t *a, char *val) if (val[len-1] == '>') { hs = strdup(val+1); *(hs+len-2) = '\0'; -#ifdef WITH_CGRAPH val = agstrdup_html(agraphof(obj),hs); -#else - val = agstrdup_html(hs); -#endif free(hs); } } -#ifndef WITH_CGRAPH - agxset(obj, a->index, val); -#else agxset(obj, a, val); -#endif } char *setv(Agraph_t *g, Agsym_t *a, char *val) { @@ -274,10 +209,8 @@ char *getv(Agnode_t *n, Agsym_t *a) { if (!n || !a) return NULL; -#ifdef WITH_CGRAPH if (AGTYPE(n) == AGRAPH) // protonode return NULL; // FIXME ?? -#endif return myagxget(n, a); } char *getv(Agnode_t *n, char *attr) @@ -287,26 +220,18 @@ char *getv(Agnode_t *n, char *attr) if (!n || !attr) return NULL; -#ifdef WITH_CGRAPH if (AGTYPE(n) == AGRAPH) // protonode return NULL; // FIXME ?? -#endif g = agroot(agraphof(n)); -#ifdef WITH_CGRAPH a = agattr(g, AGNODE, attr, NULL); -#else - a = agfindattr(g->proto->n, attr); -#endif return myagxget(n, a); } char *setv(Agnode_t *n, Agsym_t *a, char *val) { if (!n || !a || !val) return NULL; -#ifdef WITH_CGRAPH if (AGTYPE(n) == AGRAPH) // protonode return NULL; // FIXME ?? -#endif myagxset(n, a, val); return val; } @@ -317,20 +242,14 @@ char *setv(Agnode_t *n, char *attr, char *val) if (!n || !attr || !val) return NULL; -#ifdef WITH_CGRAPH if (AGTYPE(n) == AGRAPH) { // protonode g = (Agraph_t*)n; a = agattr(g, AGNODE, attr, val); // create default attribute in psuodo protonode // FIXME? - deal with html in "label" attributes return val; } -#endif g = agroot(agraphof(n)); -#ifdef WITH_CGRAPH a = agattr(g, AGNODE, attr, NULL); -#else - a = agfindattr(g->proto->n, attr); -#endif if (!a) a = agnodeattr(g, attr, emptystring); myagxset(n, a, val); @@ -341,10 +260,8 @@ char *getv(Agedge_t *e, Agsym_t *a) { if (!e || !a) return NULL; -#ifdef WITH_CGRAPH if (AGTYPE(e) == AGRAPH) // protoedge return NULL; // FIXME ?? -#endif return myagxget(e, a); } char *getv(Agedge_t *e, char *attr) @@ -354,26 +271,18 @@ char *getv(Agedge_t *e, char *attr) if (!e || !attr) return NULL; -#ifdef WITH_CGRAPH if (AGTYPE(e) == AGRAPH) // protoedge return NULL; // FIXME ?? -#endif g = agraphof(agtail(e)); -#ifndef WITH_CGRAPH - a = agfindattr(g->proto->e, attr); -#else a = agattr(g, AGEDGE, attr, NULL); -#endif return myagxget(e, a); } char *setv(Agedge_t *e, Agsym_t *a, char *val) { if (!e || !a || !val) return NULL; -#ifdef WITH_CGRAPH if (AGTYPE(e) == AGRAPH) // protoedge return NULL; // FIXME ?? -#endif myagxset(e, a, val); return val; } @@ -384,24 +293,16 @@ char *setv(Agedge_t *e, char *attr, char *val) if (!e || !attr || !val) return NULL; -#ifdef WITH_CGRAPH if (AGTYPE(e) == AGRAPH) { // protoedge g = (Agraph_t*)e; a = agattr(g, AGEDGE, attr, val); // create default attribute in pseudo protoedge // FIXME? - deal with html in "label" attributes return val; } -#endif g = agroot(agraphof(agtail(e))); -#ifndef WITH_CGRAPH - a = agfindattr(g->proto->e, attr); - if (!a) - a = agedgeattr(g, attr, emptystring); -#else a = agattr(g, AGEDGE, attr, NULL); if (!a) a = agattr(g, AGEDGE, attr, emptystring); -#endif myagxset(e, a, val); return val; } @@ -410,32 +311,22 @@ Agraph_t *findsubg(Agraph_t *g, char *name) { if (!g || !name) return NULL; -#ifndef WITH_CGRAPH - return agfindsubg(g, name); -#else return agsubg(g, name, 0); -#endif } Agnode_t *findnode(Agraph_t *g, char *name) { if (!g || !name) return NULL; -#ifndef WITH_CGRAPH - return agfindnode(g, name); -#else return agnode(g, name, 0); -#endif } Agedge_t *findedge(Agnode_t *t, Agnode_t *h) { if (!t || !h) return NULL; -#ifdef WITH_CGRAPH if (AGTYPE(t) == AGRAPH || AGTYPE(h) == AGRAPH) return NULL; -#endif return agfindedge(agraphof(t), t, h); } @@ -466,10 +357,8 @@ Agnode_t *headof(Agedge_t *e) { if (!e) return NULL; -#ifdef WITH_CGRAPH if (AGTYPE(e) == AGRAPH) return NULL; -#endif return aghead(e); } @@ -477,10 +366,8 @@ Agnode_t *tailof(Agedge_t *e) { if (!e) return NULL; -#ifdef WITH_CGRAPH if (AGTYPE(e) == AGRAPH) return NULL; -#endif return agtail(e); } @@ -495,10 +382,8 @@ Agraph_t *graphof(Agedge_t *e) { if (!e) return NULL; -#ifdef WITH_CGRAPH if (AGTYPE(e) == AGRAPH) return (Agraph_t*)e; /* graph of protoedge is itself recast */ -#endif return agraphof(agtail(e)); } @@ -506,10 +391,8 @@ Agraph_t *graphof(Agnode_t *n) { if (!n) return NULL; -#ifdef WITH_CGRAPH if (AGTYPE(n) == AGRAPH) return (Agraph_t*)n; /* graph of protonode is itself recast */ -#endif return agraphof(n); } @@ -525,22 +408,14 @@ Agnode_t *protonode(Agraph_t *g) { if (!g) return NULL; -#ifdef WITH_CGRAPH return (Agnode_t *)g; // gross abuse of the type system! -#else - return g->proto->n; -#endif } Agedge_t *protoedge(Agraph_t *g) { if (!g) return NULL; -#ifdef WITH_CGRAPH return (Agedge_t *)g; // gross abuse of the type system! -#else - return g->proto->e; -#endif } //------------------------------------------------- @@ -554,20 +429,16 @@ char *nameof(Agnode_t *n) { if (!n) return NULL; -#ifdef WITH_CGRAPH if (AGTYPE(n) == AGRAPH) return NULL; -#endif return agnameof(n); } //char *nameof(Agedge_t *e) //{ // if (!e) // return NULL; -//#ifdef WITH_CGRAPH // if (AGTYPE(e) == AGRAPH) // return NULL; -//#endif // return agnameof(e); //} char *nameof(Agsym_t *a) @@ -605,61 +476,19 @@ bool ok(Agsym_t *a) //------------------------------------------------- Agraph_t *firstsubg(Agraph_t *g) { -#ifndef WITH_CGRAPH - Agraph_t *mg; - Agnode_t *n; - Agedge_t *e; -#endif - if (!g) return NULL; -#ifdef WITH_CGRAPH return agfstsubg(g); -#else - n = g->meta_node; - if (!n) - return NULL; - mg = agraphof(n); - if (!mg) - return NULL; - e = agfstout(mg, n); - if (!e) - return NULL; - return agusergraph(aghead(e)); -#endif } Agraph_t *nextsubg(Agraph_t *g, Agraph_t *sg) { -#ifndef WITH_CGRAPH - Agraph_t *mg; - Agnode_t *ng, *nsg; - Agedge_t *e; -#endif if (!g || !sg) return NULL; -#ifdef WITH_CGRAPH return agnxtsubg(sg); -#else - ng = g->meta_node; - nsg = sg->meta_node; - if (!ng || !nsg) - return NULL; - mg = agraphof(ng); - if (!mg) - return NULL; - e = agfindedge(mg, ng, nsg); - if (!e) - return NULL; - e = agnxtout(mg, e); - if (!e) - return NULL; - return agusergraph(aghead(e)); -#endif } -#ifdef WITH_CGRAPH Agraph_t *firstsupg(Agraph_t *g) { return g->parent; @@ -669,51 +498,6 @@ Agraph_t *nextsupg(Agraph_t *g, Agraph_t *sg) { return NULL; } -#else -Agraph_t *firstsupg(Agraph_t *g) -{ - Agraph_t *mg; - Agnode_t *n; - Agedge_t *e; - - if (!g) - return NULL; - n = g->meta_node; - if (!n) - return NULL; - mg = agraphof(n); - if (!mg) - return NULL; - e = agfstin(mg, n); - if (!e) - return NULL; - return agusergraph(agtail(e)); -} - -Agraph_t *nextsupg(Agraph_t *g, Agraph_t *sg) -{ - Agraph_t *mg; - Agnode_t *ng, *nsg; - Agedge_t *e; - - if (!g || !sg) - return NULL; - ng = g->meta_node; - nsg = sg->meta_node; - if (!ng || !nsg) - return NULL; - mg = agraphof(ng); - if (!mg) - return NULL; - e = agfindedge(mg, nsg, ng); - if (!e) - return NULL; - e = agnxtin(mg, e); - if (!e) - return NULL; - return agusergraph(agtail(e)); -} -#endif Agedge_t *firstout(Agraph_t *g) { @@ -921,13 +705,7 @@ Agsym_t *firstattr(Agraph_t *g) if (!g) return NULL; g = agroot(g); -#ifdef WITH_CGRAPH return agnxtattr(g,AGRAPH,NULL); -#else - if (dtsize(g->univ->globattr->dict) == 0) - return NULL; - return g->univ->globattr->list[0]; -#endif } Agsym_t *nextattr(Agraph_t *g, Agsym_t *a) @@ -937,17 +715,7 @@ Agsym_t *nextattr(Agraph_t *g, Agsym_t *a) if (!g || !a) return NULL; g = agroot(g); -#ifdef WITH_CGRAPH return agnxtattr(g,AGRAPH,a); -#else - for (i = 0; i < dtsize(g->univ->globattr->dict); i++) - if (a == g->univ->globattr->list[i]) - break; - i++; - if (i > dtsize(g->univ->globattr->dict)) - return NULL; - return g->univ->globattr->list[i]; -#endif } Agsym_t *firstattr(Agnode_t *n) @@ -957,13 +725,7 @@ Agsym_t *firstattr(Agnode_t *n) if (!n) return NULL; g = agraphof(n); -#ifdef WITH_CGRAPH return agnxtattr(g,AGNODE,NULL); -#else - if (dtsize(g->univ->nodeattr->dict) == 0) - return NULL; - return g->univ->nodeattr->list[0]; -#endif } Agsym_t *nextattr(Agnode_t *n, Agsym_t *a) @@ -974,17 +736,7 @@ Agsym_t *nextattr(Agnode_t *n, Agsym_t *a) if (!n || !a) return NULL; g = agraphof(n); -#ifdef WITH_CGRAPH return agnxtattr(g,AGNODE,a); -#else - for (i = 0; i < dtsize(g->univ->nodeattr->dict); i++) - if (a == g->univ->nodeattr->list[i]) - break; - i++; - if (i > dtsize(g->univ->nodeattr->dict)) - return NULL; - return g->univ->nodeattr->list[i]; -#endif } Agsym_t *firstattr(Agedge_t *e) @@ -994,13 +746,7 @@ Agsym_t *firstattr(Agedge_t *e) if (!e) return NULL; g = agraphof(agtail(e)); -#ifdef WITH_CGRAPH return agnxtattr(g,AGEDGE,NULL); -#else - if (dtsize(g->univ->edgeattr->dict) == 0) - return NULL; - return g->univ->edgeattr->list[0]; -#endif } Agsym_t *nextattr(Agedge_t *e, Agsym_t *a) @@ -1011,17 +757,7 @@ Agsym_t *nextattr(Agedge_t *e, Agsym_t *a) if (!e || !a) return NULL; g = agraphof(agtail(e)); -#ifdef WITH_CGRAPH return agnxtattr(g,AGEDGE,a); -#else - for (i = 0; i < dtsize(g->univ->edgeattr->dict); i++) - if (a == g->univ->edgeattr->list[i]) - break; - i++; - if (i > dtsize(g->univ->edgeattr->dict)) - return NULL; - return g->univ->edgeattr->list[i]; -#endif } bool rm(Agraph_t *g) @@ -1030,7 +766,6 @@ bool rm(Agraph_t *g) if (!g) return false; -#ifdef WITH_CGRAPH Agraph_t* sg; for (sg = agfstsubg (g); sg; sg = agnxtsubg (sg)) rm(sg); @@ -1039,22 +774,6 @@ bool rm(Agraph_t *g) else agdelete(agroot(g), g); return true; -#else - if (g->meta_node) { - for (e = agfstout(g->meta_node->graph, g->meta_node); e; - e = agnxtout(g->meta_node->graph, e)) { - rm(agusergraph(aghead(e))); - } - if (g == agroot(g)) { - agclose(g); - } else { - agdelete(g->meta_node->graph, g); - } - return true; - } - fprintf(stderr, "subgraph has no meta_node\n"); - return false; -#endif } bool rm(Agnode_t *n) diff --git a/tclpkg/tcldot/Makefile.am b/tclpkg/tcldot/Makefile.am index 7989e0283..ab31111b8 100644 --- a/tclpkg/tcldot/Makefile.am +++ b/tclpkg/tcldot/Makefile.am @@ -3,12 +3,6 @@ SUBDIRS = demo -if WITH_CGRAPH -GRAPH = cgraph -else -GRAPH = graph -endif - # tclhandle still needed for gd TCLHANDLE_INCLUDES=-I$(top_srcdir)/tclpkg/tclhandle TCLHANDLE_LIBS=$(top_builddir)/tclpkg/tclhandle/libtclhandle_C.la @@ -22,7 +16,7 @@ AM_CPPFLAGS = \ -I$(top_srcdir) \ -I$(top_srcdir)/lib/gvc \ -I$(top_srcdir)/lib/common \ - -I$(top_srcdir)/lib/$(GRAPH) \ + -I$(top_srcdir)/lib/cgraph \ -I$(top_srcdir)/lib/cdt \ -I$(top_srcdir)/lib/pathplan $(TCLHANDLE_INCLUDES) $(GD_INCLUDES) $(TCL_INCLUDES) @@ -62,7 +56,7 @@ libtcldot_la_LDFLAGS = -no-undefined libtcldot_la_LIBADD = $(TCLHANDLE_LIBS) \ $(top_builddir)/tclpkg/tclstubs/libtclstubs_C.la \ $(top_builddir)/lib/cdt/libcdt.la \ - $(top_builddir)/lib/$(GRAPH)/lib$(GRAPH).la \ + $(top_builddir)/lib/cgraph/libcgraph.la \ $(top_builddir)/lib/pathplan/libpathplan_C.la \ $(top_builddir)/lib/gvc/libgvc.la @@ -92,7 +86,7 @@ libtcldot_builtin_la_LIBADD = $(TCLHANDLE_LIBS) \ $(top_builddir)/plugin/neato_layout/libgvplugin_neato_layout_C.la \ $(top_builddir)/plugin/core/libgvplugin_core_C.la \ $(top_builddir)/lib/gvc/libgvc_C.la \ - $(top_builddir)/lib/$(GRAPH)/lib$(GRAPH)_C.la \ + $(top_builddir)/lib/cgraph/libcgraph_C.la \ $(top_builddir)/lib/cdt/libcdt_C.la \ $(top_builddir)/lib/pathplan/libpathplan_C.la \ $(top_builddir)/tclpkg/tclstubs/libtclstubs_C.la $(GTS_LIBS) diff --git a/tclpkg/tcldot/tcldot-edgecmd.c b/tclpkg/tcldot/tcldot-edgecmd.c index 9d842c5c5..a25908af6 100644 --- a/tclpkg/tcldot/tcldot-edgecmd.c +++ b/tclpkg/tcldot/tcldot-edgecmd.c @@ -26,44 +26,26 @@ int edgecmd(ClientData clientData, Tcl_Interp * interp, Agraph_t *g; Agedge_t *e; Agsym_t *a; -#ifndef WITH_CGRAPH - char buf[32]; - Agedge_t **ep; - ictx_t *ictx = (ictx_t *)clientData; -#else gctx_t *gctx = (gctx_t *)clientData; ictx_t *ictx = gctx->ictx; -#endif GVC_t *gvc = ictx->gvc; if (argc < 2) { Tcl_AppendResult(interp, "Wrong # args: should be \"", argv[0], "\" option ?arg arg ...?", NULL); return TCL_ERROR; } -#ifndef WITH_CGRAPH - if (!(ep = (Agedge_t **) tclhandleXlate(ictx->edgeTblPtr, argv[0]))) { - Tcl_AppendResult(interp, "Edge \"", argv[0], "\" not found", NULL); - return TCL_ERROR; - } - e = *ep; -#else e = cmd2e(argv[0]); if (!e) { Tcl_AppendResult(interp, "Edge \"", argv[0], "\" not found", NULL); return TCL_ERROR; } -#endif g = agraphof(agtail(e)); c = argv[1][0]; length = strlen(argv[1]); if ((c == 'd') && (strncmp(argv[1], "delete", length) == 0)) { -#ifndef WITH_CGRAPH - deleteEdge(ictx, g, e); -#else deleteEdge(gctx, g, e); -#endif reset_layout(gvc, g); return TCL_OK; @@ -73,18 +55,8 @@ int edgecmd(ClientData clientData, Tcl_Interp * interp, return TCL_OK; } else if ((c == 'l') && (strncmp(argv[1], "listnodes", length) == 0)) { -#ifndef WITH_CGRAPH - tclhandleString(ictx->nodeTblPtr, buf, AGID(agtail(e))); - Tcl_AppendElement(interp, buf); -#else Tcl_AppendElement(interp, obj2cmd(agtail(e))); -#endif -#ifndef WITH_CGRAPH - tclhandleString(ictx->nodeTblPtr, buf, AGID(aghead(e))); - Tcl_AppendElement(interp, buf); -#else Tcl_AppendElement(interp, obj2cmd(aghead(e))); -#endif return TCL_OK; } else if ((c == 'q') @@ -96,11 +68,7 @@ int edgecmd(ClientData clientData, Tcl_Interp * interp, return TCL_ERROR; for (j = 0; j < argc2; j++) { if ((a = agfindedgeattr(g, argv2[j]))) { -#ifndef WITH_CGRAPH - Tcl_AppendElement(interp, agxget(e, a->index)); -#else Tcl_AppendElement(interp, agxget(e, a)); -#endif } else { Tcl_AppendResult(interp, "No attribute named \"", argv2[j], "\"", NULL); return TCL_ERROR; @@ -119,11 +87,7 @@ int edgecmd(ClientData clientData, Tcl_Interp * interp, for (j = 0; j < argc2; j++) { if ((a = agfindedgeattr(g, argv2[j]))) { Tcl_AppendElement(interp, argv2[j]); -#ifndef WITH_CGRAPH - Tcl_AppendElement(interp, agxget(e, a->index)); -#else Tcl_AppendElement(interp, agxget(e, a)); -#endif } else { Tcl_AppendResult(interp, "No attribute named \"", argv2[j], "\"", NULL); return TCL_ERROR; diff --git a/tclpkg/tcldot/tcldot-graphcmd.c b/tclpkg/tcldot/tcldot-graphcmd.c index e54371120..95d7932c1 100644 --- a/tclpkg/tcldot/tcldot-graphcmd.c +++ b/tclpkg/tcldot/tcldot-graphcmd.c @@ -25,16 +25,8 @@ int graphcmd(ClientData clientData, Tcl_Interp * interp, Agraph_t *g, *sg; Agnode_t *n, *tail, *head; Agedge_t *e; -#ifndef WITH_CGRAPH - Agraph_t **gp, **sgp; - Agnode_t **np; - Agedge_t **ep; - ictx_t *ictx = (ictx_t *)clientData; - unsigned long id; -#else gctx_t *gctx = (gctx_t *)clientData; ictx_t *ictx = gctx->ictx; -#endif Agsym_t *a; char c, buf[256], **argv2; int i, j, length, argc2, rc; @@ -45,19 +37,11 @@ int graphcmd(ClientData clientData, Tcl_Interp * interp, Tcl_AppendResult(interp, "Wrong # args: should be \"", argv[0], " option ?arg arg ...?\"", NULL); return TCL_ERROR; } -#ifndef WITH_CGRAPH - if (!(gp = (Agraph_t **) tclhandleXlate(ictx->graphTblPtr, argv[0]))) { - Tcl_AppendResult(interp, "Graph \"", argv[0], "\" not found", NULL); - return TCL_ERROR; - } - g = *gp; -#else g = cmd2g(argv[0]); if (!g) { Tcl_AppendResult(interp, "Graph \"", argv[0], "\" not found", NULL); return TCL_ERROR; } -#endif c = argv[1][0]; length = strlen(argv[1]); @@ -69,17 +53,6 @@ int graphcmd(ClientData clientData, Tcl_Interp * interp, NULL); return TCL_ERROR; } -#ifndef WITH_CGRAPH - if (!(np = (Agnode_t **) tclhandleXlate(ictx->nodeTblPtr, argv[2]))) { - if (!(tail = agfindnode(g, argv[2]))) { - Tcl_AppendResult(interp, "Tail node \"", argv[2], "\" not found.", NULL); - return TCL_ERROR; - } - } - else { - tail = *np; - } -#else tail = cmd2n(argv[2]); if (!tail) { if (!(tail = agfindnode(g, argv[2]))) { @@ -87,22 +60,10 @@ int graphcmd(ClientData clientData, Tcl_Interp * interp, return TCL_ERROR; } } -#endif if (agroot(g) != agroot(agraphof(tail))) { Tcl_AppendResult(interp, "Tail node ", argv[2], " is not in the graph.", NULL); return TCL_ERROR; } -#ifndef WITH_CGRAPH - if (!(np = (Agnode_t **) tclhandleXlate(ictx->nodeTblPtr, argv[3]))) { - if (!(head = agfindnode(g, argv[3]))) { - Tcl_AppendResult(interp, "Head node \"", argv[3], "\" not found.", NULL); - return TCL_ERROR; - } - } - else { - head = *np; - } -#else head = cmd2n(argv[2]); if (!head) { if (!(head = agfindnode(g, argv[3]))) { @@ -110,33 +71,12 @@ int graphcmd(ClientData clientData, Tcl_Interp * interp, return TCL_ERROR; } } -#endif if (agroot(g) != agroot(agraphof(head))) { Tcl_AppendResult(interp, "Head node ", argv[3], " is not in the graph.", NULL); return TCL_ERROR; } -#ifndef WITH_CGRAPH - e = agedge(g, tail, head); -#else e = agedge(g, tail, head, NULL, 1); Tcl_AppendResult(interp, obj2cmd(e), NULL); -#endif -#ifndef WITH_CGRAPH - if (!(ep = (Agedge_t **) tclhandleXlateIndex(ictx->edgeTblPtr, AGID(e))) || *ep != e) { - ep = (Agedge_t **) tclhandleAlloc(ictx->edgeTblPtr, Tcl_GetStringResult(interp), &id); - *ep = e; - AGID(e) = id; -#ifndef TCLOBJ - Tcl_CreateCommand(interp, Tcl_GetStringResult(interp), edgecmd, - (ClientData) ictx, (Tcl_CmdDeleteProc *) NULL); -#else /* TCLOBJ */ - Tcl_CreateObjCommand(interp, Tcl_GetStringResult(interp), edgecmd, - (ClientData) ictx, (Tcl_CmdDeleteProc *) NULL); -#endif /* TCLOBJ */ - } else { - tclhandleString(ictx->edgeTblPtr, Tcl_GetStringResult(interp), AGID(e)); - } -#endif setedgeattributes(agroot(g), e, &argv[4], argc - 4); reset_layout(gvc, g); return TCL_OK; @@ -144,51 +84,13 @@ int graphcmd(ClientData clientData, Tcl_Interp * interp, } else if ((c == 'a') && (strncmp(argv[1], "addnode", length) == 0)) { if (argc % 2) { /* if odd number of args then argv[2] is name */ -#ifdef WITH_CGRAPH n = agnode(g, argv[2], 1); -#else - n = agnode(g, argv[2]); - if (!(np = (Agnode_t **) tclhandleXlateIndex(ictx->nodeTblPtr, AGID(n))) || *np != n) { - np = (Agnode_t **) tclhandleAlloc(ictx->nodeTblPtr, Tcl_GetStringResult(interp), &id); - *np = n; - AGID(n) = id; -#ifndef TCLOBJ - Tcl_CreateCommand(interp, Tcl_GetStringResult(interp), nodecmd, - (ClientData) ictx, (Tcl_CmdDeleteProc *) NULL); -#else /* TCLOBJ */ - Tcl_CreateObjCommand(interp, Tcl_GetStringResult(interp), nodecmd, - (ClientData) ictx, (Tcl_CmdDeleteProc *) NULL); -#endif /* TCLOBJ */ - } else { - tclhandleString(ictx->nodeTblPtr, Tcl_GetStringResult(interp), AGID(n)); - } -#endif i = 3; } else { -#ifdef WITH_CGRAPH n = agnode(g, NULL, 1); /* anon node */ -#else - /* else use handle as name */ - np = (Agnode_t **) tclhandleAlloc(ictx->nodeTblPtr, Tcl_GetStringResult(interp), &id); - n = agnode(g, Tcl_GetStringResult(interp)); - *np = n; - AGID(n) = id; -#ifndef TCLOBJ - Tcl_CreateCommand(interp, Tcl_GetStringResult(interp), nodecmd, - (ClientData) ictx, (Tcl_CmdDeleteProc *) NULL); -#else /* TCLOBJ */ - Tcl_CreateObjCommand(interp, Tcl_GetStringResult(interp), nodecmd, - (ClientData) ictx, (Tcl_CmdDeleteProc *) NULL); -#endif /* TCLOBJ */ -#endif i = 2; } -#ifndef WITH_CGRAPH - np = (Agnode_t **)tclhandleXlateIndex(ictx->nodeTblPtr, AGID(n)); - *np = n; -#else Tcl_AppendResult(interp, obj2cmd(n), NULL); -#endif setnodeattributes(agroot(g), n, &argv[i], argc - i); reset_layout(gvc, g); return TCL_OK; @@ -202,50 +104,13 @@ int graphcmd(ClientData clientData, Tcl_Interp * interp, } if (argc % 2) { /* if odd number of args then argv[2] is name */ -#ifdef WITH_CGRAPH sg = agsubg(g, argv[2], 1); Tcl_AppendResult(interp, obj2cmd(sg), NULL); -#else - sg = agsubg(g, argv[2]); - if (! (sgp = (Agraph_t **) tclhandleXlateIndex(ictx->graphTblPtr, AGID(sg))) || *sgp != sg) { - sgp = (Agraph_t **) tclhandleAlloc(ictx->graphTblPtr, Tcl_GetStringResult(interp), &id); - *sgp = sg; - AGID(sg) = id; -#ifndef TCLOBJ - Tcl_CreateCommand(interp, Tcl_GetStringResult(interp), graphcmd, - (ClientData) ictx, (Tcl_CmdDeleteProc *) NULL); -#else - Tcl_CreateObjCommand(interp, Tcl_GetStringResult(interp), graphcmd, - (ClientData) ictx, (Tcl_CmdDeleteProc *) NULL); -#endif - } else { - tclhandleString(ictx->graphTblPtr, Tcl_GetStringResult(interp), AGID(sg)); - } -#endif i = 3; } else { -#ifdef WITH_CGRAPH sg = agsubg(g, NULL, 1); /* anon subgraph */ -#else - /* else use handle as name */ - sgp = (Agraph_t **) tclhandleAlloc(ictx->graphTblPtr, Tcl_GetStringResult(interp), &id); - sg = agsubg(g, Tcl_GetStringResult(interp)); - *sgp = sg; - AGID(sg) = id; -#ifndef TCLOBJ - Tcl_CreateCommand(interp, Tcl_GetStringResult(interp), graphcmd, - (ClientData) ictx, (Tcl_CmdDeleteProc *) NULL); -#else - Tcl_CreateObjCommand(interp, Tcl_GetStringResult(interp), graphcmd, - (ClientData) ictx, (Tcl_CmdDeleteProc *) NULL); -#endif -#endif i = 2; } -#ifndef WITH_CGRAPH - sgp = (Agraph_t **)tclhandleXlateIndex(ictx->graphTblPtr, AGID(sg)); - *sgp = sg; -#endif setgraphattributes(sg, &argv[i], argc - i); reset_layout(gvc, g); return TCL_OK; @@ -262,11 +127,7 @@ int graphcmd(ClientData clientData, Tcl_Interp * interp, } else if ((c == 'd') && (strncmp(argv[1], "delete", length) == 0)) { reset_layout(gvc, g); -#ifndef WITH_CGRAPH - deleteGraph(ictx, g); -#else deleteGraph(gctx, g); -#endif return TCL_OK; } else if ((c == 'f') && (strncmp(argv[1], "findedge", length) == 0)) { @@ -287,12 +148,7 @@ int graphcmd(ClientData clientData, Tcl_Interp * interp, Tcl_AppendResult(interp, "Edge \"", argv[2], " - ", argv[3], "\" not found.", NULL); return TCL_ERROR; } -#ifndef WITH_CGRAPH - tclhandleString(ictx->edgeTblPtr, buf, AGID(e)); - Tcl_AppendElement(interp, buf); -#else Tcl_AppendElement(interp, obj2cmd(e)); -#endif return TCL_OK; } else if ((c == 'f') && (strncmp(argv[1], "findnode", length) == 0)) { @@ -304,33 +160,20 @@ int graphcmd(ClientData clientData, Tcl_Interp * interp, Tcl_AppendResult(interp, "Node not found.", NULL); return TCL_ERROR; } -#ifndef WITH_CGRAPH - tclhandleString(ictx->nodeTblPtr, buf, AGID(n)); - Tcl_AppendResult(interp, buf, NULL); -#else Tcl_AppendResult(interp, obj2cmd(n), NULL); -#endif return TCL_OK; } else if ((c == 'l') && (strncmp(argv[1], "layoutedges", length) == 0)) { g = agroot(g); -#ifndef WITH_CGRAPH - if (!GD_drawing(g)) -#else if (!aggetrec (g, "Agraphinfo_t",0)) -#endif tcldot_layout(gvc, g, (argc > 2) ? argv[2] : NULL); return TCL_OK; } else if ((c == 'l') && (strncmp(argv[1], "layoutnodes", length) == 0)) { g = agroot(g); -#ifndef WITH_CGRAPH - if (!GD_drawing(g)) -#else if (!aggetrec (g, "Agraphinfo_t",0)) -#endif tcldot_layout(gvc, g, (argc > 2) ? argv[2] : NULL); return TCL_OK; @@ -352,24 +195,14 @@ int graphcmd(ClientData clientData, Tcl_Interp * interp, } else if ((c == 'l') && (strncmp(argv[1], "listedges", length) == 0)) { for (n = agfstnode(g); n; n = agnxtnode(g, n)) { for (e = agfstout(g, n); e; e = agnxtout(g, e)) { -#ifndef WITH_CGRAPH - tclhandleString(ictx->edgeTblPtr, buf, AGID(e)); - Tcl_AppendElement(interp, buf); -#else Tcl_AppendElement(interp, obj2cmd(e)); -#endif } } return TCL_OK; } else if ((c == 'l') && (strncmp(argv[1], "listnodes", length) == 0)) { for (n = agfstnode(g); n; n = agnxtnode(g, n)) { -#ifndef WITH_CGRAPH - tclhandleString(ictx->nodeTblPtr, buf, AGID(n)); - Tcl_AppendElement(interp, buf); -#else Tcl_AppendElement(interp, obj2cmd(n)); -#endif } return TCL_OK; @@ -377,31 +210,15 @@ int graphcmd(ClientData clientData, Tcl_Interp * interp, } else if ((c == 'l') && (strncmp(argv[1], "listnodesrev", length) == 0)) { for (n = aglstnode(g); n; n = agprvnode(g, n)) { -#ifndef WITH_CGRAPH - tclhandleString(ictx->nodeTblPtr, buf, AGID(n)); - Tcl_AppendElement(interp, buf); -#else Tcl_AppendElement(interp, obj2cmd(n)); -#endif } return TCL_OK; } else if ((c == 'l') && (strncmp(argv[1], "listsubgraphs", length) == 0)) { -#ifdef WITH_CGRAPH for (sg = agfstsubg(g); sg; sg = agnxtsubg(sg)) { Tcl_AppendElement(interp, obj2cmd(g)); } -#else - if (g->meta_node) { - for (e = agfstout(g->meta_node->graph, g->meta_node); e; - e = agnxtout(g->meta_node->graph, e)) { - sg = agusergraph(aghead(e)); - tclhandleString(ictx->graphTblPtr, buf, AGID(sg)); - Tcl_AppendElement(interp, buf); - } - } -#endif return TCL_OK; } else if ((c == 'q') @@ -413,11 +230,7 @@ int graphcmd(ClientData clientData, Tcl_Interp * interp, return TCL_ERROR; for (j = 0; j < argc2; j++) { if ((a = agfindgraphattr(g, argv2[j]))) { -#ifndef WITH_CGRAPH - Tcl_AppendElement(interp, agxget(g, a->index)); -#else Tcl_AppendElement(interp, agxget(g, a)); -#endif } else { Tcl_AppendResult(interp, " No attribute named \"", argv2[j], "\"", NULL); return TCL_ERROR; @@ -438,11 +251,7 @@ int graphcmd(ClientData clientData, Tcl_Interp * interp, for (j = 0; j < argc2; j++) { if ((a = agfindgraphattr(g, argv2[j]))) { Tcl_AppendElement(interp, argv2[j]); -#ifndef WITH_CGRAPH - Tcl_AppendElement(interp, agxget(g, a->index)); -#else Tcl_AppendElement(interp, agxget(g, a)); -#endif } else { Tcl_AppendResult(interp, " No attribute named \"", argv2[j], "\"", NULL); return TCL_ERROR; @@ -461,11 +270,7 @@ int graphcmd(ClientData clientData, Tcl_Interp * interp, return TCL_ERROR; for (j = 0; j < argc2; j++) { if ((a = agfindedgeattr(g, argv2[j]))) { -#ifndef WITH_CGRAPH - Tcl_AppendElement(interp, agxget(g->proto->e, a->index)); -#else Tcl_AppendElement(interp, agxget(g, a)); -#endif } else { Tcl_AppendResult(interp, " No attribute named \"", argv2[j], "\"", NULL); return TCL_ERROR; @@ -485,11 +290,7 @@ int graphcmd(ClientData clientData, Tcl_Interp * interp, for (j = 0; j < argc2; j++) { if ((a = agfindedgeattr(g, argv2[j]))) { Tcl_AppendElement(interp, argv2[j]); -#ifndef WITH_CGRAPH - Tcl_AppendElement(interp, agxget(g->proto->e, a->index)); -#else Tcl_AppendElement(interp, agxget(g, a)); -#endif } else { Tcl_AppendResult(interp, " No attribute named \"", argv2[j], "\"", NULL); @@ -509,11 +310,7 @@ int graphcmd(ClientData clientData, Tcl_Interp * interp, return TCL_ERROR; for (j = 0; j < argc2; j++) { if ((a = agfindnodeattr(g, argv2[j]))) { -#ifndef WITH_CGRAPH - Tcl_AppendElement(interp, agxget(g->proto->n, a->index)); -#else Tcl_AppendElement(interp, agxget(g, a)); -#endif } else { Tcl_AppendResult(interp, " No attribute named \"", argv2[j], "\"", NULL); @@ -535,11 +332,7 @@ int graphcmd(ClientData clientData, Tcl_Interp * interp, for (j = 0; j < argc2; j++) { if ((a = agfindnodeattr(g, argv2[j]))) { Tcl_AppendElement(interp, argv2[j]); -#ifndef WITH_CGRAPH - Tcl_AppendElement(interp, agxget(g->proto->n, a->index)); -#else Tcl_AppendElement(interp, agxget(g, a)); -#endif } else { Tcl_AppendResult(interp, " No attribute named \"", argv2[j], "\"", NULL); return TCL_ERROR; @@ -584,11 +377,7 @@ int graphcmd(ClientData clientData, Tcl_Interp * interp, /* make sure that layout is done */ g = agroot(g); -#ifndef WITH_CGRAPH - if (!GD_drawing(g) || argc > 3) -#else if (!aggetrec (g, "Agraphinfo_t",0) || argc > 3) -#endif tcldot_layout (gvc, g, (argc > 3) ? argv[3] : NULL); /* render graph TK canvas commands */ @@ -625,11 +414,7 @@ int graphcmd(ClientData clientData, Tcl_Interp * interp, /* make sure that layout is done */ g = agroot(g); -#ifndef WITH_CGRAPH - if (!GD_drawing(g) || argc > 4) -#else if (!aggetrec (g, "Agraphinfo_t",0) || argc > 4) -#endif tcldot_layout(gvc, g, (argc > 4) ? argv[4] : NULL); gvc->common.viewNum = 0; @@ -689,11 +474,7 @@ int graphcmd(ClientData clientData, Tcl_Interp * interp, Tcl_Free((char *) argv2); return TCL_ERROR; } -#ifndef WITH_CGRAPH - setedgeattributes(g, g->proto->e, argv2, argc2); -#else setedgeattributes(g, NULL, argv2, argc2); -#endif Tcl_Free((char *) argv2); } else { if ((argc < 4) || (argc % 2)) { @@ -701,11 +482,7 @@ int graphcmd(ClientData clientData, Tcl_Interp * interp, "\" setedgeattributes attributename attributevalue ?attributename attributevalue? ?...?", NULL); } -#ifndef WITH_CGRAPH - setedgeattributes(g, g->proto->e, &argv[2], argc - 2); -#else setedgeattributes(g, NULL, &argv[2], argc - 2); -#endif } reset_layout(gvc, g); return TCL_OK; @@ -724,11 +501,7 @@ int graphcmd(ClientData clientData, Tcl_Interp * interp, Tcl_Free((char *) argv2); return TCL_ERROR; } -#ifndef WITH_CGRAPH - setnodeattributes(g, g->proto->n, argv2, argc2); -#else setnodeattributes(g, NULL, argv2, argc2); -#endif Tcl_Free((char *) argv2); } else { if ((argc < 4) || (argc % 2)) { @@ -736,11 +509,7 @@ int graphcmd(ClientData clientData, Tcl_Interp * interp, "\" setnodeattributes attributename attributevalue ?attributename attributevalue? ?...?", NULL); } -#ifndef WITH_CGRAPH - setnodeattributes(g, g->proto->n, &argv[2], argc - 2); -#else setnodeattributes(g, NULL, &argv[2], argc - 2); -#endif } reset_layout(gvc, g); return TCL_OK; @@ -799,11 +568,7 @@ int graphcmd(ClientData clientData, Tcl_Interp * interp, job->output_filename = NULL; /* make sure that layout is done - unless canonical output */ -#ifndef WITH_CGRAPH - if ((!GD_drawing(g) || argc > 4) && !(job->flags & LAYOUT_NOT_REQUIRED)) -#else if ((!aggetrec (g, "Agraphinfo_t",0) || argc > 4) && !(job->flags & LAYOUT_NOT_REQUIRED)) -#endif tcldot_layout(gvc, g, (argc > 4) ? argv[4] : NULL); gvc->common.viewNum = 0; diff --git a/tclpkg/tcldot/tcldot-id.c b/tclpkg/tcldot/tcldot-id.c index 978cc4649..564081177 100644 --- a/tclpkg/tcldot/tcldot-id.c +++ b/tclpkg/tcldot/tcldot-id.c @@ -14,8 +14,6 @@ #include "tcldot.h" -#ifdef WITH_CGRAPH - // Agiddisc functions static void *myiddisc_open(Agraph_t *g, Agdisc_t *disc) { ictx_t *ictx = (ictx_t *)disc; @@ -107,4 +105,3 @@ Agiddisc_t myiddisc = { myiddisc_close, myiddisc_idregister }; -#endif diff --git a/tclpkg/tcldot/tcldot-io.c b/tclpkg/tcldot/tcldot-io.c index 6e4750a9d..41fce9b03 100644 --- a/tclpkg/tcldot/tcldot-io.c +++ b/tclpkg/tcldot/tcldot-io.c @@ -14,7 +14,6 @@ #include "tcldot.h" -#ifdef WITH_CGRAPH /* * myiodisc_afread - same api as read for libcgraph * @@ -107,98 +106,6 @@ int myiodisc_memiofread(void *chan, char *buf, int bufsize) return l; } -#else -/* - * mygets - same api as gets - * - * gets one line at a time from a Tcl_Channel and places it in a user buffer - * up to a maximum of n characters - * - * returns pointer to obtained line in user buffer, or - * returns NULL when last line read from memory buffer - * - * This is probably innefficient because it introduces - * one more stage of line buffering during reads (at least) - * but it is needed so that we can take full advantage - * of the Tcl_Channel mechanism. - */ - -char *mygets(char *ubuf, int n, FILE * channel) -{ - static Tcl_DString dstr; - static int strpos; - - if (!n) { /* a call with n==0 (from aglexinit) resets */ - *ubuf = '\0'; - strpos = 0; - return NULL; - } - - /* - * the user buffer might not be big enough to hold the line. - */ - if (strpos) { - if (Tcl_DStringLength(&dstr) > (n + strpos)) { - /* chunk between first and last */ - strncpy(ubuf, (strpos + Tcl_DStringValue(&dstr)), n - 1); - strpos += (n - 1); - ubuf[n] = '\0'; - } else { - /* last chunk */ - strcpy(ubuf, (strpos + Tcl_DStringValue(&dstr))); - strpos = 0; - } - } else { - Tcl_DStringFree(&dstr); - Tcl_DStringInit(&dstr); - if (Tcl_Gets((Tcl_Channel) channel, &dstr) < 0) { - /* probably EOF, but could be other read errors */ - *ubuf = '\0'; - return NULL; - } - /* linend char(s) were stripped off by Tcl_Gets, - * append a canonical linenend. */ - Tcl_DStringAppend(&dstr, "\n", 1); - if (Tcl_DStringLength(&dstr) >= n) { - /* first chunk */ - strncpy(ubuf, Tcl_DStringValue(&dstr), n - 1); - strpos = n - 1; - ubuf[n] = '\0'; - } else { - /* single chunk */ - strcpy(ubuf, Tcl_DStringValue(&dstr)); - } - } - return ubuf; - -#if 0 - if (!n) { /* a call with n==0 (from aglexinit) resets */ - mempos = (char *) mbuf; /* cast from FILE* required by API */ - } - - clp = to = ubuf; - for (i = 0; i < n - 1; i++) { /* leave room for terminator */ - if (*mempos == '\0') { - if (i) { /* if mbuf doesn't end in \n, provide one */ - *to++ = '\n'; - } else { /* all done */ - clp = NULL; - mempos = NULL; - } - break; /* last line or end-of-buffer */ - } - if (*mempos == '\n') { - *to++ = *mempos++; - break; /* all done with this line */ - } - *to++ = *mempos++; /* copy character */ - } - *to++ = '\0'; /* place terminator in ubuf */ - return clp; -#endif -} -#endif /* WITH_CGRAPH */ - #if 0 Agraph_t *agread_usergets (ictx_t *ictx, FILE * fp, int (*usergets)(void *chan, char *buf, int bufsize)) { diff --git a/tclpkg/tcldot/tcldot-nodecmd.c b/tclpkg/tcldot/tcldot-nodecmd.c index 0199d95f6..764f985cf 100644 --- a/tclpkg/tcldot/tcldot-nodecmd.c +++ b/tclpkg/tcldot/tcldot-nodecmd.c @@ -27,35 +27,19 @@ int nodecmd(ClientData clientData, Tcl_Interp * interp, Agnode_t *n, *head; Agedge_t *e; Agsym_t *a; -#ifndef WITH_CGRAPH - char buf[32]; - unsigned long id; - Agnode_t **np; - Agedge_t **ep; - ictx_t *ictx = (ictx_t *)clientData; -#else gctx_t *gctx = (gctx_t *)clientData; ictx_t *ictx = gctx->ictx; -#endif GVC_t *gvc = ictx->gvc; if (argc < 2) { Tcl_AppendResult(interp, "Wrong # args: should be \"", argv[0], " option ?arg arg ...?\"", NULL); return TCL_ERROR; } -#ifndef WITH_CGRAPH - if (!(np = (Agnode_t **) tclhandleXlate(ictx->nodeTblPtr, argv[0]))) { - Tcl_AppendResult(interp, "Node \"", argv[0], "\" not found", NULL); - return TCL_ERROR; - } - n = *np; -#else n = cmd2n(argv[0]); if (!n) { Tcl_AppendResult(interp, "Node \"", argv[0], "\" not found", NULL); return TCL_ERROR; } -#endif g = agraphof(n); c = argv[1][0]; @@ -67,16 +51,6 @@ int nodecmd(ClientData clientData, Tcl_Interp * interp, Tcl_AppendResult(interp, "Wrong # args: should be \"", argv[0], " addedge head ?attributename attributevalue? ?...?\"", NULL); return TCL_ERROR; } -#ifndef WITH_CGRAPH - if (!(np = (Agnode_t **) tclhandleXlate(ictx->nodeTblPtr, argv[2]))) { - if (!(head = agfindnode(g, argv[2]))) { - Tcl_AppendResult(interp, "Head node \"", argv[2], "\" not found.", NULL); - return TCL_ERROR; - } - } else { - head = *np; - } -#else head = cmd2n(argv[2]); if (!head) { if (!(head = agfindnode(g, argv[2]))) { @@ -84,43 +58,18 @@ int nodecmd(ClientData clientData, Tcl_Interp * interp, return TCL_ERROR; } } -#endif if (agroot(g) != agroot(agraphof(head))) { Tcl_AppendResult(interp, "Nodes ", argv[0], " and ", argv[2], " are not in the same graph.", NULL); return TCL_ERROR; } -#ifdef WITH_CGRAPH - e = agedge(g, n, head, NULL, 1); + e = agedge(g, n, head, NULL, 1); Tcl_AppendResult(interp, obj2cmd(e), NULL); -#else - e = agedge(g, n, head); - if (!(ep = (Agedge_t **) tclhandleXlateIndex(ictx->edgeTblPtr, AGID(e))) || *ep != e) { - ep = (Agedge_t **) tclhandleAlloc(ictx->edgeTblPtr, Tcl_GetStringResult(interp), &id); - *ep = e; - AGID(e) = id; -#ifndef TCLOBJ - Tcl_CreateCommand(interp, Tcl_GetStringResult(interp), edgecmd, - (ClientData) ictx, - (Tcl_CmdDeleteProc *) NULL); -#else /* TCLOBJ */ - Tcl_CreateObjCommand(interp, Tcl_GetStringResult(interp), edgecmd, - (ClientData) ictx, - (Tcl_CmdDeleteProc *) NULL); -#endif /* TCLOBJ */ - } else { - tclhandleString(ictx->edgeTblPtr, Tcl_GetStringResult(interp), AGID(e)); - } -#endif setedgeattributes(agroot(g), e, &argv[3], argc - 3); reset_layout(gvc, g); return TCL_OK; } else if ((c == 'd') && (strncmp(argv[1], "delete", length) == 0)) { -#ifndef WITH_CGRAPH - deleteNode(ictx, g, n); -#else deleteNode(gctx, g, n); -#endif reset_layout(gvc, g); return TCL_OK; @@ -134,20 +83,10 @@ int nodecmd(ClientData clientData, Tcl_Interp * interp, return TCL_ERROR; } if (!(e = agfindedge(g, n, head))) { -#ifndef WITH_CGRAPH - tclhandleString(ictx->nodeTblPtr, buf, AGID(head)); - Tcl_AppendResult(interp, "Edge \"", argv[0], " - ", buf, "\" not found.", NULL); -#else Tcl_AppendResult(interp, "Edge \"", argv[0], " - ", obj2cmd(head), "\" not found.", NULL); -#endif return TCL_ERROR; } -#ifndef WITH_CGRAPH - tclhandleString(ictx->edgeTblPtr, buf, AGID(e)); - Tcl_AppendElement(interp, buf); -#else Tcl_AppendElement(interp, obj2cmd(head)); -#endif return TCL_OK; } else if ((c == 'l') @@ -157,36 +96,21 @@ int nodecmd(ClientData clientData, Tcl_Interp * interp, } else if ((c == 'l') && (strncmp(argv[1], "listedges", length) == 0)) { for (e = agfstedge(g, n); e; e = agnxtedge(g, e, n)) { -#ifndef WITH_CGRAPH - tclhandleString(ictx->edgeTblPtr, buf, AGID(e)); - Tcl_AppendElement(interp, buf); -#else Tcl_AppendElement(interp, obj2cmd(e)); -#endif } return TCL_OK; } else if ((c == 'l') && (strncmp(argv[1], "listinedges", length) == 0)) { for (e = agfstin(g, n); e; e = agnxtin(g, e)) { -#ifndef WITH_CGRAPH - tclhandleString(ictx->edgeTblPtr, buf, AGID(e)); - Tcl_AppendElement(interp, buf); -#else Tcl_AppendElement(interp, obj2cmd(e)); -#endif } return TCL_OK; } else if ((c == 'l') && (strncmp(argv[1], "listoutedges", length) == 0)) { for (e = agfstout(g, n); e; e = agnxtout(g, e)) { -#ifndef WITH_CGRAPH - tclhandleString(ictx->edgeTblPtr, buf, AGID(e)); - Tcl_AppendElement(interp, buf); -#else Tcl_AppendElement(interp, obj2cmd(e)); -#endif } return TCL_OK; @@ -199,11 +123,7 @@ int nodecmd(ClientData clientData, Tcl_Interp * interp, return TCL_ERROR; for (j = 0; j < argc2; j++) { if ((a = agfindnodeattr(g, argv2[j]))) { -#ifndef WITH_CGRAPH - Tcl_AppendElement(interp, agxget(n, a->index)); -#else Tcl_AppendElement(interp, agxget(n, a)); -#endif } else { Tcl_AppendResult(interp, "No attribute named \"", argv2[j], "\"", NULL); return TCL_ERROR; @@ -224,11 +144,7 @@ int nodecmd(ClientData clientData, Tcl_Interp * interp, for (j = 0; j < argc2; j++) { if ((a = agfindnodeattr(g, argv2[j]))) { Tcl_AppendElement(interp, argv2[j]); -#ifndef WITH_CGRAPH - Tcl_AppendElement(interp, agxget(n, a->index)); -#else Tcl_AppendElement(interp, agxget(n, a)); -#endif } else { Tcl_AppendResult(interp, "No attribute named \"", argv2[j], "\"", NULL); return TCL_ERROR; diff --git a/tclpkg/tcldot/tcldot-util.c b/tclpkg/tcldot/tcldot-util.c index 530017648..eeeccdf2f 100644 --- a/tclpkg/tcldot/tcldot-util.c +++ b/tclpkg/tcldot/tcldot-util.c @@ -25,19 +25,6 @@ size_t Tcldot_channel_writer(GVJ_t *job, const char *s, size_t len) return Tcl_Write((Tcl_Channel)(job->output_file), s, len); } -void reset_layout(GVC_t *gvc, Agraph_t * sg) -{ -#ifndef WITH_CGRAPH - Agraph_t *g = agroot(sg); - - if (GD_drawing(g)) { /* only cleanup once between layouts */ - gvFreeLayout(gvc, g); - GD_drawing(g) = NULL; - } -#endif -} - -#ifdef WITH_CGRAPH /* handles (tcl commands) to obj* */ Agraph_t *cmd2g(char *cmd) { @@ -77,9 +64,7 @@ char *obj2cmd (void *obj) { return buf; } -#endif // WITH_CGRAPH -#ifdef WITH_CGRAPH void deleteEdge(gctx_t *gctx, Agraph_t * g, Agedge_t *e) { char *hndl; @@ -138,84 +123,6 @@ void deleteGraph(gctx_t * gctx, Agraph_t *g) } Tcl_DeleteCommand(gctx->ictx->interp, hndl); } -#else -void deleteEdge(ictx_t * ictx, Agraph_t * g, Agedge_t *e) -{ - Agedge_t **ep; - char buf[32]; - - tclhandleString(ictx->edgeTblPtr, buf, AGID(e)); - Tcl_DeleteCommand(ictx->interp, buf); - ep = (Agedge_t **) tclhandleXlateIndex(ictx->edgeTblPtr, AGID(e)); - if (!ep) - fprintf(stderr, "Bad entry in edgeTbl\n"); - tclhandleFreeIndex(ictx->edgeTblPtr, AGID(e)); - agdelete(agroot(g), e); -} -static void deleteNodeEdges(ictx_t * ictx, Agraph_t * g, Agnode_t * n) -{ - Agedge_t *e, *e1; - - e = agfstedge(g, n); - while (e) { - e1 = agnxtedge(g, e, n); - deleteEdge(ictx, g, e); - e = e1; - } -} -void deleteNode(ictx_t * ictx, Agraph_t * g, Agnode_t *n) -{ - Agnode_t **np; - char buf[32]; - - deleteNodeEdges(ictx, agroot(g), n); - tclhandleString(ictx->nodeTblPtr, buf, AGID(n)); - Tcl_DeleteCommand(ictx->interp, buf); - np = (Agnode_t **) tclhandleXlateIndex(ictx->nodeTblPtr, AGID(n)); - if (!np) - fprintf(stderr, "Bad entry in nodeTbl\n"); - tclhandleFreeIndex(ictx->nodeTblPtr, AGID(n)); - agdelete(agroot(g), n); -} -static void deleteGraphNodes(ictx_t * ictx, Agraph_t * g) -{ - Agnode_t *n, *n1; - - n = agfstnode(g); - while (n) { - n1 = agnxtnode(g, n); - deleteNode(ictx, g, n); - n = n1; - } -} -void deleteGraph(ictx_t * ictx, Agraph_t * g) -{ - Agraph_t **sgp; - Agedge_t *e; - char buf[32]; - - if (g->meta_node) { - for (e = agfstout(g->meta_node->graph, g->meta_node); e; - e = agnxtout(g->meta_node->graph, e)) { - deleteGraph(ictx, agusergraph(aghead(e))); - } - tclhandleString(ictx->graphTblPtr, buf, AGID(g)); - Tcl_DeleteCommand(ictx->interp, buf); - sgp = (Agraph_t **) tclhandleXlateIndex(ictx->graphTblPtr, AGID(g)); - if (!sgp) - fprintf(stderr, "Bad entry in graphTbl\n"); - tclhandleFreeIndex(ictx->graphTblPtr, AGID(g)); - deleteGraphNodes(ictx, g); - if (g == agroot(g)) { - agclose(g); - } else { - agdelete(g->meta_node->graph, g->meta_node); - } - } else { - fprintf(stderr, "Subgraph has no meta_node\n"); - } -} -#endif void setgraphattributes(Agraph_t * g, char *argv[], int argc) { @@ -223,15 +130,9 @@ void setgraphattributes(Agraph_t * g, char *argv[], int argc) Agsym_t *a; for (i = 0; i < argc; i++) { -#ifndef WITH_CGRAPH - if (!(a = agfindgraphattr(agroot(g), argv[i]))) - a = agraphattr(agroot(g), argv[i], ""); - agxset(g, a->index, argv[++i]); -#else if (!(a = agfindgraphattr(agroot(g), argv[i]))) a = agattr(agroot(g), AGRAPH, argv[i], ""); agxset(g, a, argv[++i]); -#endif } } @@ -246,11 +147,6 @@ void setedgeattributes(Agraph_t * g, Agedge_t * e, char *argv[], int argc) i++; continue; } -#ifndef WITH_CGRAPH - if (!(a = agfindedgeattr(g, argv[i]))) - a = agedgeattr(agroot(g), argv[i], ""); - agxset(e, a->index, argv[++i]); -#else if (e) { if (!(a = agfindedgeattr(g, argv[i]))) a = agattr(agroot(g), AGEDGE, argv[i], ""); @@ -260,7 +156,6 @@ void setedgeattributes(Agraph_t * g, Agedge_t * e, char *argv[], int argc) agattr(g, AGEDGE, argv[i], argv[i+1]); i++; } -#endif } } @@ -270,11 +165,6 @@ void setnodeattributes(Agraph_t * g, Agnode_t * n, char *argv[], int argc) Agsym_t *a; for (i = 0; i < argc; i++) { -#ifndef WITH_CGRAPH - if (!(a = agfindnodeattr(g, argv[i]))) - a = agnodeattr(agroot(g), argv[i], ""); - agxset(n, a->index, argv[++i]); -#else if (n) { if (!(a = agfindnodeattr(g, argv[i]))) a = agattr(agroot(g), AGNODE, argv[i], ""); @@ -284,11 +174,9 @@ void setnodeattributes(Agraph_t * g, Agnode_t * n, char *argv[], int argc) agattr(g, AGNODE, argv[i], argv[i+1]); i++; } -#endif } } -#ifdef WITH_CGRAPH void listGraphAttrs (Tcl_Interp * interp, Agraph_t* g) { Agsym_t *a = NULL; @@ -310,38 +198,6 @@ void listEdgeAttrs (Tcl_Interp * interp, Agraph_t* g) Tcl_AppendElement(interp, a->name); } } -#else -void listGraphAttrs (Tcl_Interp * interp, Agraph_t* g) -{ - int i; - Agsym_t *a; - - for (i = 0; i < dtsize(g->univ->globattr->dict); i++) { - a = g->univ->globattr->list[i]; - Tcl_AppendElement(interp, a->name); - } -} -void listNodeAttrs (Tcl_Interp * interp, Agraph_t* g) -{ - int i; - Agsym_t *a; - - for (i = 0; i < dtsize(g->univ->nodeattr->dict); i++) { - a = g->univ->nodeattr->list[i]; - Tcl_AppendElement(interp, a->name); - } -} -void listEdgeAttrs (Tcl_Interp * interp, Agraph_t* g) -{ - int i; - Agsym_t *a; - - for (i = 0; i < dtsize(g->univ->edgeattr->dict); i++) { - a = g->univ->edgeattr->list[i]; - Tcl_AppendElement(interp, a->name); - } -} -#endif void tcldot_layout(GVC_t *gvc, Agraph_t * g, char *engine) { @@ -349,11 +205,7 @@ void tcldot_layout(GVC_t *gvc, Agraph_t * g, char *engine) Agsym_t *a; int rc; -#ifndef WITH_CGRAPH - reset_layout(gvc, g); /* in case previously drawn */ -#else gvFreeLayout(gvc, g); /* in case previously drawn */ -#endif /* support old behaviors if engine isn't specified*/ if (!engine || *engine == '\0') { @@ -392,13 +244,7 @@ void tcldot_layout(GVC_t *gvc, Agraph_t * g, char *engine) sprintf(buf, "%d %d %d %d", ROUND(GD_bb(g).LL.x), ROUND(GD_bb(g).LL.y), ROUND(GD_bb(g).UR.x), ROUND(GD_bb(g).UR.y)); -#ifndef WITH_CGRAPH - if (!(a = agfindgraphattr(g, "bb"))) - a = agraphattr(g, "bb", ""); - agxset(g, a->index, buf); -#else if (!(a = agattr(g, AGRAPH, "bb", NULL))) a = agattr(g, AGRAPH, "bb", ""); agxset(g, a, buf); -#endif } diff --git a/tclpkg/tcldot/tcldot.c b/tclpkg/tcldot/tcldot.c index 33696bb53..50c8efc8e 100644 --- a/tclpkg/tcldot/tcldot.c +++ b/tclpkg/tcldot/tcldot.c @@ -26,13 +26,7 @@ static int dotnew(ClientData clientData, Tcl_Interp * interp, Agraph_t *g; char c; int i, length; -#ifndef WITH_CGRAPH - Agraph_t **gp; - int kind; - unsigned long id; -#else Agdesc_t kind; -#endif if ((argc < 2)) { Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], @@ -43,157 +37,39 @@ static int dotnew(ClientData clientData, Tcl_Interp * interp, c = argv[1][0]; length = strlen(argv[1]); if ((c == 'd') && (strncmp(argv[1], "digraph", length) == 0)) { -#ifndef WITH_CGRAPH - kind = AGDIGRAPH; -#else kind = Agdirected; -#endif } else if ((c == 'd') && (strncmp(argv[1], "digraphstrict", length) == 0)) { -#ifndef WITH_CGRAPH - kind = AGDIGRAPHSTRICT; -#else kind = Agstrictdirected; -#endif } else if ((c == 'g') && (strncmp(argv[1], "graph", length) == 0)) { -#ifndef WITH_CGRAPH - kind = AGRAPH; -#else kind = Agundirected; -#endif } else if ((c == 'g') && (strncmp(argv[1], "graphstrict", length) == 0)) { -#ifndef WITH_CGRAPH - kind = AGRAPHSTRICT; -#else kind = Agstrictundirected; -#endif } else { Tcl_AppendResult(interp, "bad graphtype \"", argv[1], "\": must be one of:", "\n\tdigraph, digraphstrict, graph, graphstrict.", NULL); return TCL_ERROR; } -#ifndef WITH_CGRAPH - gp = (Agraph_t **) tclhandleAlloc(ictx->graphTblPtr, Tcl_GetStringResult(interp), &id); -#endif if (argc % 2) { /* if odd number of args then argv[2] is name */ -#ifndef WITH_CGRAPH - g = agopen(argv[2], kind); -#else g = agopen(argv[2], kind, (Agdisc_t*)ictx); -#endif i = 3; } else { /* else use handle as name */ -#ifndef WITH_CGRAPH - g = agopen(Tcl_GetStringResult(interp), kind); -#else g = agopen(Tcl_GetStringResult(interp), kind, (Agdisc_t*)ictx); -#endif i = 2; } if (!g) { Tcl_AppendResult(interp, "\nFailure to open graph.", NULL); return TCL_ERROR; } -#ifndef WITH_CGRAPH - *gp = g; - AGID(g) = id; -#ifndef TCLOBJ - Tcl_CreateCommand(interp, Tcl_GetStringResult(interp), graphcmd, - (ClientData) ictx, (Tcl_CmdDeleteProc *) NULL); -#else /* TCLOBJ */ - Tcl_CreateObjCommand(interp, Tcl_GetStringResult(interp), graphcmd, - (ClientData) ictx, (Tcl_CmdDeleteProc *) NULL); -#endif /* TCLOBJ */ -#endif setgraphattributes(g, &argv[i], argc - i); - -#ifndef WITH_CGRAPH - /* we use GD_drawing(g) as a flag that layout has been done. - * so we make sure that it is initialized to "not done" */ - GD_drawing(g) = NULL; -#else Tcl_AppendResult(interp, obj2cmd(g), NULL); -#endif return TCL_OK; } -#ifndef WITH_CGRAPH -/* - * when a graph is read in from a file or string we need to walk - * it to create the handles and tcl commands for each - * graph, subgraph, node, and edge. - */ -static int tcldot_fixup(ictx_t *ictx, graph_t * g) -{ - Agraph_t **gp, *sg, **sgp; - Agnode_t *n, **np; - Agedge_t *e, **ep; - char buf[32]; - unsigned long id; - Tcl_Interp *interp = ictx->interp; - - if (g->meta_node) { - for (n = agfstnode(g->meta_node->graph); n; - n = agnxtnode(g->meta_node->graph, n)) { - sg = agusergraph(n); - sgp = (Agraph_t **) tclhandleAlloc(ictx->graphTblPtr, buf, &id); - *sgp = sg; - AGID(sg) = id; -#ifndef TCLOBJ - Tcl_CreateCommand(interp, buf, graphcmd, (ClientData) ictx, - (Tcl_CmdDeleteProc *) NULL); -#else /* TCLOBJ */ - Tcl_CreateObjCommand(interp, buf, graphcmd, (ClientData) ictx, - (Tcl_CmdDeleteProc *) NULL); -#endif /* TCLOBJ */ - if (sg == g) - Tcl_SetResult(interp, buf, TCL_VOLATILE); - } - } else { - gp = (Agraph_t **) tclhandleAlloc(ictx->graphTblPtr, Tcl_GetStringResult(interp), &id); - *gp = g; - AGID(g) = id; -#ifndef TCLOBJ - Tcl_CreateCommand(interp, Tcl_GetStringResult(interp), graphcmd, - (ClientData) ictx, (Tcl_CmdDeleteProc *) NULL); -#else /* TCLOBJ */ - Tcl_CreateObjCommand(interp, Tcl_GetStringResult(interp), graphcmd, - (ClientData) ictx, (Tcl_CmdDeleteProc *) NULL); -#endif /* TCLOBJ */ - } - for (n = agfstnode(g); n; n = agnxtnode(g, n)) { - np = (Agnode_t **) tclhandleAlloc(ictx->nodeTblPtr, buf, &id); - *np = n; - AGID(n) = id; -#ifndef TCLOBJ - Tcl_CreateCommand(interp, buf, nodecmd, - (ClientData) ictx, (Tcl_CmdDeleteProc *) NULL); -#else /* TCLOBJ */ - Tcl_CreateObjCommand(interp, buf, nodecmd, - (ClientData) gvc, (Tcl_CmdDeleteProc *) NULL); -#endif /* TCLOBJ */ - for (e = agfstout(g, n); e; e = agnxtout(g, e)) { - ep = (Agedge_t **) tclhandleAlloc(ictx->edgeTblPtr, buf, &id); - *ep = e; - AGID(e) = id; -#ifndef TCLOBJ - Tcl_CreateCommand(interp, buf, edgecmd, (ClientData) ictx, - (Tcl_CmdDeleteProc *) NULL); -#else /* TCLOBJ */ - Tcl_CreateObjCommand(interp, buf, edgecmd, (ClientData) gvc, - (Tcl_CmdDeleteProc *) NULL); -#endif /* TCLOBJ */ - } - } - return TCL_OK; -} - -#endif /* WITH_CGRAPH */ - static int dotread(ClientData clientData, Tcl_Interp * interp, #ifndef TCLOBJ int argc, char *argv[] @@ -205,11 +81,9 @@ static int dotread(ClientData clientData, Tcl_Interp * interp, Agraph_t *g; Tcl_Channel channel; int mode; -#ifdef WITH_CGRAPH ictx_t *ictx = (ictx_t *)clientData; ictx->myioDisc.afread = myiodisc_afread; /* replace afread to use Tcl Channels */ -#endif if (argc < 2) { Tcl_AppendResult(interp, "Wrong # args: should be \"", argv[0], " fileHandle\"", NULL); @@ -226,11 +100,7 @@ static int dotread(ClientData clientData, Tcl_Interp * interp, * a properly parsed graph. If the graph doesn't parse * during reading then the channel will be left at EOF */ -#ifndef WITH_CGRAPH - g = agread_usergets((FILE *) channel, (mygets)); -#else g = agread ((FILE*)channel, (Agdisc_t *)clientData); -#endif if (!g) { Tcl_AppendResult(interp, "\nFailure to read graph \"", argv[1], "\"", NULL); if (agerrors()) { @@ -242,15 +112,8 @@ static int dotread(ClientData clientData, Tcl_Interp * interp, Tcl_AppendResult(interp, "\nSyntax errors in file \"", argv[1], " \"", NULL); return TCL_ERROR; } -#ifndef WITH_CGRAPH - /* we use GD_drawing(g) as a flag that layout has been done. - * so we make sure that it is initialized to "not done" */ - GD_drawing(g) = NULL; - return (tcldot_fixup((ictx_t *)clientData, g)); -#else Tcl_AppendResult(interp, obj2cmd(g), NULL); return TCL_OK; -#endif } static int dotstring(ClientData clientData, Tcl_Interp * interp, @@ -262,7 +125,6 @@ static int dotstring(ClientData clientData, Tcl_Interp * interp, ) { Agraph_t *g; -#ifdef WITH_CGRAPH ictx_t *ictx = (ictx_t *)clientData; rdr_t rdr; @@ -270,18 +132,13 @@ static int dotstring(ClientData clientData, Tcl_Interp * interp, rdr.data = argv[1]; rdr.len = strlen(rdr.data); rdr.cur = 0; -#endif if (argc < 2) { Tcl_AppendResult(interp, "Wrong # args: should be \"", argv[0], " string\"", NULL); return TCL_ERROR; } -#ifndef WITH_CGRAPH - g = agmemread(argv[1]); -#else /* agmemread() is broken for our use because it replaces the id disc */ g = agread(&rdr, (Agdisc_t *)clientData); -#endif if (!g) { Tcl_AppendResult(interp, "\nFailure to read string \"", argv[1], "\"", NULL); if (agerrors()) { @@ -293,15 +150,8 @@ static int dotstring(ClientData clientData, Tcl_Interp * interp, Tcl_AppendResult(interp, "\nSyntax errors in string \"", argv[1], " \"", NULL); return TCL_ERROR; } -#ifndef WITH_CGRAPH - /* we use GD_drawing(g) as a flag that layout has been done. - * so we make sure that it is initialized to "not done" */ - GD_drawing(g) = NULL; - return (tcldot_fixup((ictx_t *)clientData, g)); -#else Tcl_AppendResult(interp, obj2cmd(g), NULL); return TCL_OK; -#endif } #if defined(_BLD_tcldot) && defined(_DLL) @@ -317,7 +167,6 @@ int Tcldot_Init(Tcl_Interp * interp) return TCL_ERROR; ictx->interp = interp; -#ifdef WITH_CGRAPH /* build disciplines dynamically so we can selectively replace functions */ ictx->myioDisc.afread = NULL; /* set in dotread() or dotstring() according to need */ @@ -329,7 +178,6 @@ int Tcldot_Init(Tcl_Interp * interp) ictx->mydisc.io = &(ictx->myioDisc); /* change parts */ ictx->ctr = 1; /* init to first odd number, increment by 2 */ -#endif #ifdef USE_TCL_STUBS if (Tcl_InitStubs(interp, TCL_VERSION, 0) == NULL) { @@ -348,15 +196,8 @@ int Tcldot_Init(Tcl_Interp * interp) Gdtclft_Init(interp); #endif -#ifdef WITH_CGRAPH /* set persistent attributes here */ agattr(NULL, AGNODE, "label", NODENAME_ESC); -#else - aginit(); - agsetiodisc(NULL, gvfwrite, gvferror); - /* set persistent attributes here */ - agnodeattr(NULL, "label", NODENAME_ESC); -#endif /* create a GraphViz Context and pass a pointer to it in clientdata */ gvc = gvNEWcontext(lt_preloaded_symbols, DEMAND_LOADING); @@ -365,27 +206,12 @@ int Tcldot_Init(Tcl_Interp * interp) /* configure for available plugins */ gvconfig(gvc, FALSE); -#ifndef TCLOBJ - Tcl_CreateCommand(interp, "dotnew", dotnew, - (ClientData) ictx, (Tcl_CmdDeleteProc *) NULL); - Tcl_CreateCommand(interp, "dotread", dotread, - (ClientData) ictx, (Tcl_CmdDeleteProc *) NULL); - Tcl_CreateCommand(interp, "dotstring", dotstring, - (ClientData) ictx, (Tcl_CmdDeleteProc *) NULL); -#else /* TCLOBJ */ Tcl_CreateObjCommand(interp, "dotnew", dotnew, (ClientData) ictx, (Tcl_CmdDeleteProc *) NULL); Tcl_CreateObjCommand(interp, "dotread", dotread, (ClientData) ictx, (Tcl_CmdDeleteProc *) NULL); Tcl_CreateObjCommand(interp, "dotstring", dotstring, (ClientData) ictx, (Tcl_CmdDeleteProc *) NULL); -#endif /* TCLOBJ */ - -#ifndef WITH_CGRAPH - ictx->graphTblPtr = (void *) tclhandleInit("graph", sizeof(Agraph_t *), 10); - ictx->nodeTblPtr = (void *) tclhandleInit("node", sizeof(Agnode_t *), 100); - ictx->edgeTblPtr = (void *) tclhandleInit("edge", sizeof(Agedge_t *), 100); -#endif return TCL_OK; } diff --git a/tclpkg/tcldot/tcldot.h b/tclpkg/tcldot/tcldot.h index d9ec94e62..b096030a9 100644 --- a/tclpkg/tcldot/tcldot.h +++ b/tclpkg/tcldot/tcldot.h @@ -44,18 +44,13 @@ Tcl_GetString(Tcl_Obj *obj) { * ictx - one per tcl interpreter, may support multiple graph namespaces */ typedef struct { -#ifdef WITH_CGRAPH Agdisc_t mydisc; /* must be first to allow casting mydisc to ictx */ Agiodisc_t myioDisc; unsigned long ctr; /* odd number counter for anon objects over all g's in interp */ -#else - void *graphTblPtr, *nodeTblPtr, *edgeTblPtr; -#endif Tcl_Interp *interp; GVC_t *gvc; } ictx_t; -#ifdef WITH_CGRAPH /* * gctx - one for each graph in a tcl interp */ @@ -64,18 +59,12 @@ typedef struct { ictx_t *ictx; unsigned long idx; } gctx_t; -#endif #if HAVE_LIBGD extern void *GDHandleTable; extern int Gdtclft_Init(Tcl_Interp *); #endif -#ifndef WITH_CGRAPH -#undef AGID -#define AGID(x) ((x)->handle) -#endif - extern int graphcmd(ClientData clientData, Tcl_Interp * interp, #ifndef TCLOBJ int argc, char *argv[] @@ -98,7 +87,6 @@ extern int edgecmd(ClientData clientData, Tcl_Interp * interp, #endif ); -#ifdef WITH_CGRAPH /* rdr_t isn't exposed by cgraph/io.c */ typedef struct { const char *data; @@ -120,15 +108,6 @@ extern void deleteGraph(gctx_t *gctx, Agraph_t * g); extern void listGraphAttrs (Tcl_Interp * interp, Agraph_t* g); extern void listNodeAttrs (Tcl_Interp * interp, Agraph_t* g); extern void listEdgeAttrs (Tcl_Interp * interp, Agraph_t* g); -#else -extern void deleteEdge(ictx_t * ictx, Agraph_t * g, Agedge_t * e); -extern void deleteNode(ictx_t * ictx, Agraph_t * g, Agnode_t * n); -extern void deleteGraph(ictx_t * ictx, Agraph_t * g); -extern void listGraphAttrs (Tcl_Interp * interp, Agraph_t* g); -extern void listNodeAttrs (Tcl_Interp * interp, Agraph_t* g); -extern void listEdgeAttrs (Tcl_Interp * interp, Agraph_t* g); -extern char *mygets(char *ubuf, int n, FILE * channel); -#endif extern void setgraphattributes(Agraph_t * g, char *argv[], int argc); extern void setedgeattributes(Agraph_t * g, Agedge_t * e, char *argv[], int argc); @@ -139,5 +118,3 @@ extern size_t Tcldot_channel_writer(GVJ_t *job, const char *s, size_t len); extern void tcldot_layout(GVC_t *gvc, Agraph_t * g, char *engine); extern void reset_layout(GVC_t *gvc, Agraph_t * sg); - - -- 2.40.0