* It plots!!!!
authorJoseph Pingenot <bzrdude@digitasaru.net>
Thu, 24 Jul 2008 03:44:36 +0000 (22:44 -0500)
committerJoseph Pingenot <bzrdude@digitasaru.net>
Thu, 24 Jul 2008 03:44:36 +0000 (22:44 -0500)
scdataviz.c

index 9597ec9..43e7b45 100644 (file)
 #include <graphwidget.h>
 #include <matdb-dotcode.h>
 
+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);