summaryrefslogtreecommitdiff
path: root/src/graph/layout.c
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2009-06-25 00:34:22 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2009-06-25 00:34:22 (GMT)
commitf2696c85e502e36a529a1d8ee3d209498ac2c0e9 (patch)
tree3d8ffe28a730d32c98e8d048b99f67b7856acec9 /src/graph/layout.c
parent23c7cd436e2ec980a68e6d12a6d8a750e357763c (diff)
Used Graphviz library for building graphs (first attempt).
git-svn-id: svn://svn.gna.org/svn/chrysalide/trunk@80 abbe820e-26c8-41b2-8c08-b7b2b41f8b0a
Diffstat (limited to 'src/graph/layout.c')
-rw-r--r--src/graph/layout.c93
1 files changed, 93 insertions, 0 deletions
diff --git a/src/graph/layout.c b/src/graph/layout.c
new file mode 100644
index 0000000..c76df49
--- /dev/null
+++ b/src/graph/layout.c
@@ -0,0 +1,93 @@
+
+/* OpenIDA - Outil d'analyse de fichiers binaires
+ * layout.c - mise en place de graphique
+ *
+ * Copyright (C) 2009 Cyrille Bagard
+ *
+ * This file is part of OpenIDA.
+ *
+ * OpenIDA 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 3 of the License, or
+ * (at your option) any later version.
+ *
+ * OpenIDA 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 Foobar. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+
+#include "layout.h"
+
+
+#include <malloc.h>
+#include <string.h>
+
+
+#include "dot.h"
+#include "node.h"
+#include "../common/extstr.h"
+
+
+
+/******************************************************************************
+* *
+* Paramètres : fixed = support à placer les différents éléments. *
+* views = morceaux de code à afficher de façon organisée. *
+* count = quantité de ces morceaux de code. *
+* *
+* Description : Dispose une série de morceaux d'affichage en graphique. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+bool build_graph_view(GtkFixed *fixed, GtkBinView **views, size_t count)
+{
+ GGraphNode **nodes; /* Intermédiaires en place */
+ size_t i; /* Boucle de parcours */
+ char *cmds; /* Description à envoyer à dot */
+ graph_layout *layout; /* Graphique construit */
+
+ /* Création de la glue */
+
+ nodes = (GGraphNode **)calloc(count, sizeof(GGraphNode *));
+
+ for (i = 0; i < count; i++)
+ nodes[i] = g_graph_node_new(views[i]);
+
+ /* Définition du graphique */
+
+ cmds = strdup("digraph G {\n");
+
+ for (i = 0; i < count; i++)
+ cmds = g_graph_node_register_for_dot(nodes[i], cmds);
+
+
+
+
+ cmds = stradd(cmds, "}");
+
+ printf("first step :: '%s'\n", cmds);
+
+ layout = create_graph_layout(cmds);
+
+ /* Affichage du graphique */
+
+ place_nodes_of_graph_layout(layout, fixed, nodes, count);
+
+
+
+ delete_graph_layout(layout);
+
+ /* TODO : free nodes */
+
+ return true;
+
+}