Commit 6845908d authored by Øyvind Kolås's avatar Øyvind Kolås

NEW files with a function to create a graphviz compatible description of a

* bin/gegl-dot.[ch]: NEW files with a function to create a graphviz
compatible description of a given graph.
* bin/Makefile.am: added gegl-dot.[ch]
* bin/gegl-options.[c]: added --dot commandline option.
* bin/gegl.c: (main): handle --dot.
parent bc4dd0d5
2006-12-27 Øyvind Kolås <pippin@gimp.org>
* bin/gegl-dot.[ch]: NEW files with a function to create a graphviz
compatible description of a given graph.
* bin/Makefile.am: added gegl-dot.[ch]
* bin/gegl-options.[c]: added --dot commandline option.
* bin/gegl.c: (main): handle --dot.
2006-12-26 Øyvind Kolås <pippin@gimp.org>
* operations/workshop/remap.c: added a operation to stretch contrast
......
......@@ -12,6 +12,7 @@ gui_sources = \
editor-optype.c \
export.c \
export.h \
gegl-dot.c \
gegl-node-editor.c \
gegl-node-editor.h \
gegl-store.c \
......
/* This file is part of GEGL editor -- a gtk frontend for GEGL
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* Copyright (C) 2006 Øyvind Kolås
*/
#include <stdio.h>
#include "gegl-plugin.h"
gchar *
gegl_to_dot (GeglNode *node)
{
GeglGraph *graph = GEGL_GRAPH (node);
GString *string = g_string_new ("digraph gegl {\n");
{
GList *nodes = gegl_graph_get_children (graph);
GList *entry = nodes;
while (entry)
{
GeglNode *node = entry->data;
gchar buf[512];
sprintf (buf, "op_%p [label=\"%s\"];\n", node, gegl_node_get_debug_name (node));
g_string_append (string, buf);
entry = g_list_next (entry);
}
g_list_free (nodes);
}
{
GList *nodes = gegl_graph_get_children (graph);
GList *entry = nodes;
while (entry)
{
GeglNode *node = entry->data;
{
GList *connections = gegl_node_get_sinks (node);
GList *entry;
entry = connections;
while (entry)
{
GeglConnection *connection = entry->data;
gchar buf[512];
GeglNode *source;
GeglNode *sink;
source = gegl_connection_get_source_node (connection);
sink = gegl_connection_get_sink_node (connection);
sprintf (buf, "op_%p -> op_%p;\n", source, sink);
g_string_append (string, buf);
entry = g_list_next (entry);
}
/* FIXME: should have needed a free, but we're working directly on
* the list,..
*/
}
entry = g_list_next (entry);
}
g_list_free (nodes);
}
g_string_append (string, "}");
return g_string_free (string, FALSE);
}
/* This file is part of GEGL editor -- a gtk frontend for GEGL
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* Copyright (C) 2006 Øyvind Kolås
*/
#ifndef GEGL_DOT_H
#define GEGL_DOT_H
#include "gegl.h"
gchar *gegl_to_dot (GeglNode *node);
#endif
......@@ -58,6 +58,8 @@ usage (char *application_name)
" --xml use xml provided in next argument\n"
" -x\n"
"\n"
" --dot output a graphviz graph description\n"
""
" --output output generated image to named file\n"
" -o (file is saved in PNG format)\n"
"\n"
......@@ -238,6 +240,10 @@ parse_args (int argc,
o->mode = GEGL_RUN_MODE_XML;
}
else if (match ("--dot")) {
o->mode = GEGL_RUN_MODE_DOT;
}
else if (match ("--")) {
o->rest = curr+1;
break;
......
......@@ -26,6 +26,7 @@
#include <string.h>
#include <unistd.h>
#include "gegl-options.h"
#include "gegl-dot.h"
#if HAVE_GTK
#include <gtk/gtk.h>
......@@ -177,6 +178,11 @@ main (gint argc,
gegl_exit ();
return 0;
break;
case GEGL_RUN_MODE_DOT:
g_print (gegl_to_dot (gegl));
gegl_exit ();
return 0;
break;
case GEGL_RUN_MODE_PNG:
{
GeglNode *output = gegl_graph_new_node (gegl,
......
/* This file is part of GEGL editor -- a gtk frontend for GEGL
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* Copyright (C) 2006 Øyvind Kolås
*/
#include <stdio.h>
#include "gegl-plugin.h"
gchar *
gegl_to_dot (GeglNode *node)
{
GeglGraph *graph = GEGL_GRAPH (node);
GString *string = g_string_new ("digraph gegl {\n");
{
GList *nodes = gegl_graph_get_children (graph);
GList *entry = nodes;
while (entry)
{
GeglNode *node = entry->data;
gchar buf[512];
sprintf (buf, "op_%p [label=\"%s\"];\n", node, gegl_node_get_debug_name (node));
g_string_append (string, buf);
entry = g_list_next (entry);
}
g_list_free (nodes);
}
{
GList *nodes = gegl_graph_get_children (graph);
GList *entry = nodes;
while (entry)
{
GeglNode *node = entry->data;
{
GList *connections = gegl_node_get_sinks (node);
GList *entry;
entry = connections;
while (entry)
{
GeglConnection *connection = entry->data;
gchar buf[512];
GeglNode *source;
GeglNode *sink;
source = gegl_connection_get_source_node (connection);
sink = gegl_connection_get_sink_node (connection);
sprintf (buf, "op_%p -> op_%p;\n", source, sink);
g_string_append (string, buf);
entry = g_list_next (entry);
}
/* FIXME: should have needed a free, but we're working directly on
* the list,..
*/
}
entry = g_list_next (entry);
}
g_list_free (nodes);
}
g_string_append (string, "}");
return g_string_free (string, FALSE);
}
/* This file is part of GEGL editor -- a gtk frontend for GEGL
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* Copyright (C) 2006 Øyvind Kolås
*/
#ifndef GEGL_DOT_H
#define GEGL_DOT_H
#include "gegl.h"
gchar *gegl_to_dot (GeglNode *node);
#endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment