]> granicus.if.org Git - graphviz/commitdiff
- add new function render() which is a wrapper for attach_attrs()
authorellson <devnull@localhost>
Fri, 27 Jan 2006 20:12:31 +0000 (20:12 +0000)
committerellson <devnull@localhost>
Fri, 27 Jan 2006 20:12:31 +0000 (20:12 +0000)
- add example python script to illustrate

lib/gvc/gvc.h
tclpkg/gv/examples/layout.py [new file with mode: 0755]
tclpkg/gv/gv.cpp
tclpkg/gv/gv.i

index 899281a5f69fd9db792a5bcecf660f9e39ab7b1f..762c1c2897db4d05568ff926385544e1b1713cba 100644 (file)
@@ -70,6 +70,9 @@ extern int gvLayout(GVC_t *gvc, graph_t *g, char *engine);
 /* Compute a layout using layout engine from command line args */
 extern int gvLayoutJobs(GVC_t *gvc, graph_t *g);
 
+/* Render layout into string attributes of the graph */
+extern void attach_attrs(graph_t *g);
+
 /* Render layout in a specified format to an open FILE */
 extern int gvRender(GVC_t *gvc, graph_t *g, char *format, FILE *out);
 
diff --git a/tclpkg/gv/examples/layout.py b/tclpkg/gv/examples/layout.py
new file mode 100755 (executable)
index 0000000..9e1c274
--- /dev/null
@@ -0,0 +1,25 @@
+#!/usr/bin/python
+
+# use layout positioning from within script
+
+import sys
+sys.path.append('/usr/lib/graphviz/python')
+import gv
+
+# create a new empty graph 
+G = gv.digraph("G")
+
+# define a simple graph ( A->B )
+gv.edge(gv.node(G, "A"),gv.node(G, "B"))
+
+# compute a directed graph layout
+gv.layout(G, 'dot')
+
+# annotate the graph with the layout information
+gv.render(G)
+
+# do something with the layout
+n = gv.firstnode(G)
+while gv.ok(n) :
+    print "node " + gv.nameof(n) + " is at " + gv.getv(n,"pos")
+    n = gv.nextnode(G,n)
index 1977b52d93ed3038da4e027f720bdaad960b2844..2445d6a20a280cefc35a20a3c7f091eec3be87eb 100644 (file)
@@ -832,25 +832,37 @@ void layout(Agraph_t *g, char *engine)
     err = gvLayout(gvc, g, engine);
 }
 
+// annotate the graph with layout information
+void render(Agraph_t *g)
+{
+    attach_attrs(g);
+}
+
+// render to a filename
 void render(Agraph_t *g, char *format, char *filename)
 {
     int err;
 
     err = gvRenderFilename(gvc, g, format, filename);
-
 }
+
+// render to stdout
 void render(Agraph_t *g, char *format)
 {
     int err;
 
     err = gvRender(gvc, g, format, stdout);
 }
+
+// render to a FILE
 void render(Agraph_t *g, char *format, FILE *f)
 {
     int err;
 
     err = gvRender(gvc, g, format, f);
 }
+
+// FIXME - render to a caller provided memory blob
 void render(Agraph_t *g, char *format, void **data)
 {
 //    FIXME
index 529c1ed7f71755a4b53db69941063924ede2f767..58935a72b52cb2fc5058758cd81793e643d017b0 100644 (file)
@@ -181,7 +181,10 @@ extern void rm(Agedge_t *e);
 extern void layout(Agraph_t *g, char *engine);
 
 /** Render */
-/*** Render a graph in a specific format */
+/*** Render a layout into attributes of the graph */
+extern void render(Agraph_t *g); 
+
+/*** Render a layout in a specific format */
 extern void render(Agraph_t *g, char *format);
 extern void render(Agraph_t *g, char *format, char *filename);
 extern void render(Agraph_t *g, char *format, FILE *f);