From b005a74b49c676278ba4159089e6bbecda4d34c4 Mon Sep 17 00:00:00 2001 From: Joseph Pingenot Date: Wed, 23 Jul 2008 22:44:36 -0500 Subject: [PATCH] * It plots!!!! --- scdataviz.c | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/scdataviz.c b/scdataviz.c index 9597ec9..43e7b45 100644 --- a/scdataviz.c +++ b/scdataviz.c @@ -31,6 +31,30 @@ #include #include +struct xy_properties { + GString *xprop; + GString *yprop; + Graph *graph; +}; + +static void put_mat_in_graph(gpointer key, gpointer value, gpointer user_data) { + struct xy_properties *propmap = user_data; + struct matdb_material *mat = value; + double *x, *y; + #ifdef DEBUG + fprintf(stderr, "put_mat_in_graph(%s) (x->%s, y->%s): ", (char*)key, propmap->xprop->str, propmap->yprop->str); + #endif + if(((x=g_hash_table_lookup(mat->properties, propmap->xprop->str)) != NULL) + && ((y=g_hash_table_lookup(mat->properties, propmap->yprop->str)) != NULL)) { + graph_add_point(propmap->graph, *x, *y); + #ifdef DEBUG + fprintf(stderr, "added (x->%s=%g, y->%s=%g)\n", propmap->xprop->str, *x, propmap->yprop->str, *y); + }else{ + fprintf(stderr, "no such properties (x->%s, y->%s)\n", propmap->xprop->str, propmap->yprop->str); + #endif + } +} + int main(int argc, char *argv[]) { GtkWidget *window; @@ -51,15 +75,23 @@ int main(int argc, char *argv[]) window = gtk_window_new (GTK_WINDOW_TOPLEVEL); graph = graph_widget_new(); - + + struct xy_properties propmap; + propmap.xprop = g_string_new("a_lc"); + propmap.yprop = g_string_new("E_g_Gamma"); + propmap.graph = graph_widget_get_graph(GRAPH_WIDGET(graph)); + g_hash_table_foreach(mdb->materials, &put_mat_in_graph, &propmap); + //Connect signals g_signal_connect(G_OBJECT(window), "destroy", G_CALLBACK(gtk_main_quit), NULL); gtk_container_add(GTK_CONTAINER(window), graph); + /* graph_add_point(graph_widget_get_graph(graph), 5, 3); graph_add_point(graph_widget_get_graph(graph), 8, 12); graph_add_point(graph_widget_get_graph(graph), 11, 48); + */ gtk_widget_show_all (window); -- 1.7.9.5