* It plots!!!!
[scdataviz] / scdataviz.c
index 0ca4468..43e7b45 100644 (file)
 
 #include <gtk/gtk.h>
 #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;
     GtkWidget *button;
     GtkWidget *graph;
+    GString *file = g_string_new("../matdb");
+    int err=0;
+    struct matdb *mdb = read_matdb_dotcode(file, &err);
+    //fprintf(stderr, "read_matdb_dotcode(%s, %d)=%x", file->str, err,
+    //(int)mdb);
+    fprintf(stderr, "err=%d\n", err);
+    print_matdb(mdb);
+    
     
     gtk_init (&argc, &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);