gegl r3046 - trunk/gegl



Author: martinn
Date: Sat Apr 11 15:34:44 2009
New Revision: 3046
URL: http://svn.gnome.org/viewvc/gegl?rev=3046&view=rev

Log:
Allow node + dependencies when constructing the graphviz dot-file

Modified:
   trunk/gegl/gegl-dot.c

Modified: trunk/gegl/gegl-dot.c
==============================================================================
--- trunk/gegl/gegl-dot.c	(original)
+++ trunk/gegl/gegl-dot.c	Sat Apr 11 15:34:44 2009
@@ -28,7 +28,10 @@
 #include "graph/gegl-node.h"
 #include "graph/gegl-pad.h"
 #include "graph/gegl-connection.h"
+#include "graph/gegl-visitable.h"
+#include "graph/gegl-visitor.h"
 #include "gegl-dot.h"
+#include "gegl-dot-visitor.h"
 #include "gegl.h"
 
 void
@@ -234,14 +237,48 @@
   g_string_append_printf (string, "}\n");
 }
 
+
+/**
+ * gegl_dot_add_node_and_dependencies:
+ * @string:
+ * @node:
+ *
+ * Adds @node to the graph, and all nodes that @node depends on both
+ * directly and indirectly. There is no grouping of subgraphs.
+ **/
+static void
+gegl_dot_add_node_and_dependencies (GString  *string,
+                                    GeglNode *node)
+{
+  GeglDotVisitor *dot_visitor;
+  gpointer        context_id = string;
+
+  dot_visitor = g_object_new (GEGL_TYPE_DOT_VISITOR,
+                              "id", context_id,
+                              NULL);
+
+  gegl_dot_visitor_set_string_to_append (dot_visitor,
+                                         string);
+
+  gegl_visitor_dfs_traverse (GEGL_VISITOR (dot_visitor),
+                             GEGL_VISITABLE (node));
+
+  g_object_unref (dot_visitor);
+}
+
 gchar *
 gegl_to_dot (GeglNode *node)
 {
   GString *string;
 
   string = g_string_new ("digraph gegl { graph [ rankdir = \"BT\"];\n");
-  gegl_dot_add_graph (string, node, "GEGL");
-  g_string_append (string, "}");
+
+  if (node->is_graph)
+    gegl_dot_add_graph (string, node, "GEGL");
+  else
+    gegl_dot_add_node_and_dependencies (string, node);
+
+  g_string_append (string, "}\n");
 
   return g_string_free (string, FALSE);
 }



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]