From: John Ellson Date: Wed, 22 Feb 2012 19:21:08 +0000 (-0500) Subject: partial implementation of stub protonode/edge X-Git-Tag: LAST_LIBGRAPH~32^2~490 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=6a6d71e5e667eac6a12013c03b079c140a312f38;p=graphviz partial implementation of stub protonode/edge --- diff --git a/tclpkg/gv/Makefile.am b/tclpkg/gv/Makefile.am index 0b5122937..9abdf5555 100644 --- a/tclpkg/gv/Makefile.am +++ b/tclpkg/gv/Makefile.am @@ -37,7 +37,7 @@ libgv_sharp_la_LDFLAGS = -module -avoid-version libgv_sharp_la_CPPFLAGS = $(BASECPPFLAGS) $(SHARP_INCLUDES) $(SHARP_data): gv_sharp.cpp gv_sharp.cpp: gv.i - $(SWIG) $(DEFS) -c++ -csharp -namespace gv -o gv_sharp.cpp $(srcdir)/gv.i + $(SWIG) -c++ -csharp -namespace gv -o gv_sharp.cpp $(srcdir)/gv.i pkggodir = $(pkglibdir)/go GO_data = @@ -48,7 +48,7 @@ libgv_go_la_LDFLAGS = -module -avoid-version libgv_go_la_CPPFLAGS = $(BASECPPFLAGS) $(GO_INCLUDES) # $(GO_data): gv_go.cpp gv_go.cpp: gv.i - $(SWIG) $(DEFS) -c++ -go -o gv_go.cpp $(srcdir)/gv.i + $(SWIG) -c++ -go -o gv_go.cpp $(srcdir)/gv.i pkgguiledir = $(pkglibdir)/guile GUILE_data = @@ -59,7 +59,7 @@ libgv_guile_la_LDFLAGS = -module -avoid-version libgv_guile_la_CPPFLAGS = $(BASECPPFLAGS) $(GUILE_INCLUDES) # $(GUILE_data): gv_guile.cpp gv_guile.cpp: gv.i - $(SWIG) $(DEFS) -c++ -guile -o gv_guile.cpp $(srcdir)/gv.i + $(SWIG) -c++ -guile -o gv_guile.cpp $(srcdir)/gv.i $(SED) -e 's/SWIG_GUILE_INIT_STATIC void/void/' t$$ mv -f t$$ gv_guile.cpp @@ -72,7 +72,7 @@ libgv_io_la_LDFLAGS = -module -avoid-version libgv_io_la_CPPFLAGS = $(BASECPPFLAGS) $(IO_INCLUDES) # $(IO_data): gv_io.cpp gv_io.cpp: gv.i - $(SWIG) $(DEFS) -c++ -io -o gv_io.cpp $(srcdir)/gv.i + $(SWIG) -c++ -io -o gv_io.cpp $(srcdir)/gv.i pkgjavadir = $(pkglibdir)/java JAVA_data = gv.java gvJNI.java SWIGTYPE_p_Agraph_t.java SWIGTYPE_p_Agnode_t.java SWIGTYPE_p_Agedge_t.java SWIGTYPE_p_Agsym_t.java SWIGTYPE_p_FILE.java @@ -83,7 +83,7 @@ libgv_java_la_LDFLAGS = -module -avoid-version libgv_java_la_CPPFLAGS = $(BASECPPFLAGS) $(JAVA_INCLUDES) $(JAVA_data): gv_java.cpp gv_java.cpp: gv.i - $(SWIG) $(DEFS) -package org.graphviz -c++ -java -o gv_java.cpp $(srcdir)/gv.i + $(SWIG) -package org.graphviz -c++ -java -o gv_java.cpp $(srcdir)/gv.i pkgluadir = $(pkglibdir)/lua LUA_data = @@ -94,7 +94,7 @@ libgv_lua_la_LDFLAGS = -module -avoid-version libgv_lua_la_CPPFLAGS = $(BASECPPFLAGS) $(LUA_INCLUDES) # $(LUA_data): gv_lua.cpp gv_lua.cpp: gv.i - $(SWIG) $(DEFS) -c++ -lua -o gv_lua.cpp $(srcdir)/gv.i + $(SWIG) -c++ -lua -o gv_lua.cpp $(srcdir)/gv.i mv $@ $@.orig sed '/include/s/malloc\.h/cstdlib/' $@.orig > $@ @@ -110,7 +110,7 @@ libgv_ocaml_la_LDFLAGS = -module -avoid-version libgv_ocaml_la_CPPFLAGS = $(BASECPPFLAGS) $(OCAML_INCLUDES) gv.ml gv.mli: gv_ocaml.cpp gv_ocaml.cpp: gv.i - $(SWIG) $(DEFS) -c++ -ocaml -o gv_ocaml.cpp $(srcdir)/gv.i + $(SWIG) -c++ -ocaml -o gv_ocaml.cpp $(srcdir)/gv.i swig.mli: $(SWIG) -ocaml -co swig.mli swig.ml: @@ -145,7 +145,7 @@ libgv_perl_la_LDFLAGS = -module -avoid-version $(PERL_LD) libgv_perl_la_CPPFLAGS = $(BASECPPFLAGS) $(PERL_CC) $(PERL_data): gv_perl.cpp gv_perl.cpp: gv.i - $(SWIG) $(DEFS) -c++ -perl -o gv_perl.cpp $(srcdir)/gv.i + $(SWIG) -c++ -perl -o gv_perl.cpp $(srcdir)/gv.i pkgphpdir = $(pkglibdir)/php PHP_data = gv.php @@ -157,7 +157,7 @@ libgv_php_la_CPPFLAGS = $(BASECPPFLAGS) $(PHP_INCLUDES) gv.php: gv_php.cpp php_gv.h: gv_php.cpp gv_php.cpp: gv.i - $(SWIG) $(DEFS) -c++ -php5 -o gv_php.cpp $(srcdir)/gv.i + $(SWIG) -c++ -php5 -o gv_php.cpp $(srcdir)/gv.i pkgpythondir = $(pkglibdir)/python PYTHON_data = gv.py @@ -168,7 +168,7 @@ libgv_python_la_LDFLAGS = -module -avoid-version libgv_python_la_CPPFLAGS = $(BASECPPFLAGS) $(PYTHON_INCLUDES) $(PYTHON_data): gv_python.cpp gv_python.cpp: gv.i - $(SWIG) $(DEFS) -c++ -python -o gv_python.cpp $(srcdir)/gv.i + $(SWIG) -c++ -python -o gv_python.cpp $(srcdir)/gv.i pkgpython23dir = $(pkglibdir)/python23 PYTHON23_data = gv.py @@ -179,7 +179,7 @@ libgv_python23_la_LDFLAGS = -module -avoid-version libgv_python23_la_CPPFLAGS = $(BASECPPFLAGS) $(PYTHON23_INCLUDES) # $(PYTHON23_data): gv_python23.cpp gv_python23.cpp: gv.i - $(SWIG) $(DEFS) -c++ -python -classic -o gv_python23.cpp $(srcdir)/gv.i + $(SWIG) -c++ -python -classic -o gv_python23.cpp $(srcdir)/gv.i pkgpython24dir = $(pkglibdir)/python24 PYTHON24_data = gv.py @@ -190,7 +190,7 @@ libgv_python24_la_LDFLAGS = -module -avoid-version libgv_python24_la_CPPFLAGS = $(BASECPPFLAGS) $(PYTHON24_INCLUDES) # $(PYTHON24_data): gv_python24.cpp gv_python24.cpp: gv.i - $(SWIG) $(DEFS) -c++ -python -classic -o gv_python24.cpp $(srcdir)/gv.i + $(SWIG) -c++ -python -classic -o gv_python24.cpp $(srcdir)/gv.i pkgpython25dir = $(pkglibdir)/python25 PYTHON25_data = gv.py @@ -201,7 +201,7 @@ libgv_python25_la_LDFLAGS = -module -avoid-version libgv_python25_la_CPPFLAGS = $(BASECPPFLAGS) $(PYTHON25_INCLUDES) # $(PYTHON25_data): gv_python25.cpp gv_python25.cpp: gv.i - $(SWIG) $(DEFS) -c++ -python -classic -o gv_python25.cpp $(srcdir)/gv.i + $(SWIG) -c++ -python -classic -o gv_python25.cpp $(srcdir)/gv.i pkgpython26dir = $(pkglibdir)/python26 PYTHON26_data = gv.py @@ -212,7 +212,7 @@ libgv_python26_la_LDFLAGS = -module -avoid-version libgv_python26_la_CPPFLAGS = $(BASECPPFLAGS) $(PYTHON26_INCLUDES) # $(PYTHON26_data): gv_python26.cpp gv_python26.cpp: gv.i - $(SWIG) $(DEFS) -c++ -python -o gv_python26.cpp $(srcdir)/gv.i + $(SWIG) -c++ -python -o gv_python26.cpp $(srcdir)/gv.i pkgpython27dir = $(pkglibdir)/python27 PYTHON27_data = gv.py @@ -223,7 +223,7 @@ libgv_python27_la_LDFLAGS = -module -avoid-version libgv_python27_la_CPPFLAGS = $(BASECPPFLAGS) $(PYTHON27_INCLUDES) # $(PYTHON27_data): gv_python27.cpp gv_python27.cpp: gv.i - $(SWIG) $(DEFS) -c++ -python -o gv_python27.cpp $(srcdir)/gv.i + $(SWIG) -c++ -python -o gv_python27.cpp $(srcdir)/gv.i pkgRdir = $(pkglibdir)/R R_data = @@ -234,7 +234,7 @@ libgv_R_la_LDFLAGS = -module -avoid-version libgv_R_la_CPPFLAGS = $(BASECPPFLAGS) $(R_CFLAGS) # $(R_data): gv_R.cpp gv_R.cpp: gv.i - $(SWIG) $(DEFS) -c++ -r -o gv_R.cpp $(srcdir)/gv.i + $(SWIG) -c++ -r -o gv_R.cpp $(srcdir)/gv.i pkgrubydir = $(pkglibdir)/ruby RUBY_data = @@ -245,7 +245,7 @@ libgv_ruby_la_LDFLAGS = -module -avoid-version libgv_ruby_la_CPPFLAGS = $(BASECPPFLAGS) $(RUBY_CFLAGS) # $(RUBY_data): gv_ruby.cpp gv_ruby.cpp: gv.i - $(SWIG) $(DEFS) -c++ -ruby -o gv_ruby.cpp $(srcdir)/gv.i + $(SWIG) -c++ -ruby -o gv_ruby.cpp $(srcdir)/gv.i pkgtcldir = $(pkglibdir)/tcl TCL_data = @@ -256,7 +256,7 @@ libgv_tcl_la_LDFLAGS = -module -avoid-version libgv_tcl_la_CPPFLAGS = $(BASECPPFLAGS) $(TCL_INCLUDES) # $(TCL_data): gv_tcl.cpp gv_tcl.cpp: gv.i - $(SWIG) $(DEFS) -c++ -tcl -namespace -o gv_tcl.cpp $(srcdir)/gv.i + $(SWIG) -c++ -tcl -namespace -o gv_tcl.cpp $(srcdir)/gv.i pkginclude_HEADERS = gv.i gv.cpp pkglib_LTLIBRARIES = diff --git a/tclpkg/gv/gv.cpp b/tclpkg/gv/gv.cpp index f847874ef..4195c423f 100644 --- a/tclpkg/gv/gv.cpp +++ b/tclpkg/gv/gv.cpp @@ -131,26 +131,32 @@ Agraph_t *graph(Agraph_t *g, char *name) Agnode_t *node(Agraph_t *g, char *name) { - // creating a protonode is not permitted - if (!gvc || (name[0] == '\001' && strcmp (name, "\001proto") == 0)) + 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) { - // edges from/to the protonode are not permitted - if (!gvc || !t || !h - || (agnameof(t)[0] == '\001' && strcmp (agnameof(t), "\001proto") == 0) - || (agnameof(h)[0] == '\001' && strcmp (agnameof(h), "\001proto") == 0)) + 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 } @@ -287,6 +293,12 @@ char *setv(Agnode_t *n, Agsym_t *a, char *val) { if (!n || !a || !val) return NULL; +#ifdef WITH_CGRAPH + if ( AGTYPE(n) == AGRAPH ) { +// agattr(sg,AGNODE,"shape","box") + // FIXME - protonode + } +#endif myagxset(n, a, val); return val; } @@ -299,6 +311,10 @@ char *setv(Agnode_t *n, char *attr, char *val) return NULL; g = agroot(agraphof(n)); #ifdef WITH_CGRAPH + if ( AGTYPE(n) == AGRAPH ) { +// agattr(sg,AGNODE,"shape","box") + // FIXME - protonode + } a = agattr(g, AGNODE, attr, NULL); #else a = agfindattr(g->proto->n, attr); @@ -332,6 +348,11 @@ char *setv(Agedge_t *e, Agsym_t *a, char *val) { if (!e || !a || !val) return NULL; +#ifdef WITH_CGRAPH + if ( AGTYPE(e) == AGRAPH ) { + // FIXME - protonode + } +#endif myagxset(e, a, val); return val; } @@ -344,6 +365,9 @@ char *setv(Agedge_t *e, char *attr, char *val) return NULL; g = agroot(agraphof(agtail(e))); #ifndef WITH_CGRAPH + if ( AGTYPE(e) == AGRAPH ) { + // FIXME - protonode + } a = agfindattr(g->proto->e, attr); if (!a) a = agedgeattr(g, attr, emptystring); @@ -460,11 +484,33 @@ Agnode_t *protonode(Agraph_t *g) } Agedge_t *protoedge(Agraph_t *g) -{ + if (!g) return NULL; return g->proto->e; } +#else +/* + * CGRAPH's default attribute values are not in a node struct. + * so fake one + */ +static Agnode_t stub_protonode; //specifically .tag == AGRAPH + +Agnode_t *protonode(Agraph_t *g) +{ + if (!g) + return NULL; + return &stub_protonode; +} + +static Agedge_t stub_protoedge; //specifically .tag == AGRAPH + +Agedge_t *protoedge(Agraph_t *g) +{ + if (!g) + return NULL; + return &stub_protoedge; +} #endif //------------------------------------------------- @@ -977,9 +1023,15 @@ bool rm(Agnode_t *n) { if (!n) return false; +#ifndef WITH_CGRAPH // removal of the protonode is not permitted if (agnameof(n)[0] == '\001' && strcmp (agnameof(n), "\001proto") ==0) return false; +#else + // removal of the protonode is not permitted + if (AGTYPE(n) == AGRAPH) + return false; +#endif agdelete(agraphof(n), n); return true; } @@ -988,10 +1040,16 @@ bool rm(Agedge_t *e) { if (!e) return false; +#ifndef WITH_CGRAPH // removal of the protoedge is not permitted if ((agnameof(aghead(e))[0] == '\001' && strcmp (agnameof(aghead(e)), "\001proto") == 0) || (agnameof(agtail(e))[0] == '\001' && strcmp (agnameof(agtail(e)), "\001proto") == 0)) return false; +#else + // removal of the protoedge is not permitted + if (AGTYPE(e) == AGRAPH) + return false; +#endif agdelete(agroot(agraphof(aghead(e))), e); return true; } diff --git a/tclpkg/gv/gv.i b/tclpkg/gv/gv.i index 22835c352..a39f1de12 100644 --- a/tclpkg/gv/gv.i +++ b/tclpkg/gv/gv.i @@ -119,10 +119,8 @@ extern Agraph_t *graphof(Agnode_t *n); extern Agraph_t *rootof(Agraph_t *g); /** Obtain handles of proto node/edge for setting default attribute values */ -#ifndef WITH_CGRAPH extern Agnode_t *protonode(Agraph_t *g); extern Agedge_t *protoedge(Agraph_t *g); -#endif /** Iterators */ /*** Iteration termination tests */